diff --git a/Lib/ctypes/test/test_pickling.py b/Lib/ctypes/test/test_pickling.py index c7925c7ac78..28868f43d2a 100644 --- a/Lib/ctypes/test/test_pickling.py +++ b/Lib/ctypes/test/test_pickling.py @@ -66,6 +66,11 @@ class PickleTest(unittest.TestCase): ]: self.assertRaises(ValueError, lambda: self.dumps(item)) + def test_wchar(self): + pickle.dumps(c_char("x")) + # Issue 5049 + pickle.dumps(c_wchar(u"x")) + class PickleTest_1(PickleTest): def dumps(self, item): return pickle.dumps(item, 1) diff --git a/Misc/NEWS b/Misc/NEWS index e1f2630da9d..546c7c1e138 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -17,9 +17,11 @@ Core and Builtins - Issue #5759: float() didn't call __float__ on str subclasses. -Librar +Library ------- +- Issue #5041: ctypes does now allow pickling wide character. + - Issue #5768: Fixed bug in Unicode output logic and test case for same. - Issue #1161031: fix readwrite select flag handling: POLLPRI now diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 43da2095cdf..7caef2902d1 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1952,7 +1952,7 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ml = &c_void_p_method; stgdict->flags |= TYPEFLAG_ISPOINTER; break; - case 'u': + case 's': case 'X': case 'O': ml = NULL;