summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-06-01 16:54:18 (GMT)
committerGitHub <noreply@github.com>2020-06-01 16:54:18 (GMT)
commita97011b9b8c8111f42e1e7594081956136d848da (patch)
treec755b7df4d7b1486d323835fb43e4195826a4599 /Lib
parente9684fac5a158be9806304a676e619857520a4dc (diff)
downloadcpython-a97011b9b8c8111f42e1e7594081956136d848da.zip
cpython-a97011b9b8c8111f42e1e7594081956136d848da.tar.gz
cpython-a97011b9b8c8111f42e1e7594081956136d848da.tar.bz2
bpo-39593: Add test on ctypes cfield.c s_set() (GH-18424)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_struct_fields.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_struct_fields.py b/Lib/ctypes/test/test_struct_fields.py
index 8045cc8..ee8415f 100644
--- a/Lib/ctypes/test/test_struct_fields.py
+++ b/Lib/ctypes/test/test_struct_fields.py
@@ -46,6 +46,14 @@ class StructFieldsTestCase(unittest.TestCase):
Y._fields_ = []
self.assertRaises(AttributeError, setattr, X, "_fields_", [])
+ def test_5(self):
+ class X(Structure):
+ _fields_ = (("char", c_char * 5),)
+
+ x = X(b'#' * 5)
+ x.char = b'a\0b\0'
+ self.assertEqual(bytes(x), b'a\x00###')
+
# __set__ and __get__ should raise a TypeError in case their self
# argument is not a ctype instance.
def test___set__(self):