mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-32745: Fix a regression in the handling of ctypes' c_wchar_p type (#8721)
Embedded nulls would cause a ValueError to be raised. Thanks go to Eryk Sun for their analysis. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
518f8b5dd5
commit
73766b0341
3 changed files with 13 additions and 1 deletions
|
@ -26,6 +26,14 @@ class UnicodeTestCase(unittest.TestCase):
|
|||
self.assertEqual(buf[::2], 'a\xe4\xfc')
|
||||
self.assertEqual(buf[6:5:-1], "")
|
||||
|
||||
def test_embedded_null(self):
|
||||
class TestStruct(ctypes.Structure):
|
||||
_fields_ = [("unicode", ctypes.c_wchar_p)]
|
||||
t = TestStruct()
|
||||
# This would raise a ValueError:
|
||||
t.unicode = "foo\0bar\0\0"
|
||||
|
||||
|
||||
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
|
||||
|
||||
class StringTestCase(UnicodeTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue