diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-09-02 18:39:40 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-09-02 18:39:40 (GMT) |
commit | 02dd539dbb2ed51165f4c8138ab16f3498877971 (patch) | |
tree | e7819436d5b5d435e760526255844ea2d93483bd /Lib/ctypes | |
parent | 172f374a63bfc61f71ee925463927a81350b66da (diff) | |
download | cpython-02dd539dbb2ed51165f4c8138ab16f3498877971.zip cpython-02dd539dbb2ed51165f4c8138ab16f3498877971.tar.gz cpython-02dd539dbb2ed51165f4c8138ab16f3498877971.tar.bz2 |
Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
a string.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 536ea50..e4530d5 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -239,6 +239,14 @@ class StructureTestCase(unittest.TestCase): pass self.assertRaises(TypeError, setattr, POINT, "_fields_", [("x", 1), ("y", 2)]) + def test_invalid_name(self): + # field name must be string + def declare_with_name(name): + class S(Structure): + _fields_ = [(name, c_int)] + + self.assertRaises(TypeError, declare_with_name, b"x") + def test_intarray_fields(self): class SomeInts(Structure): _fields_ = [("a", c_int * 4)] |