Merge from 3.2: Issue #12764: Fix a crash in ctypes when the name of a

Structure field is not a string.
This commit is contained in:
Amaury Forgeot d'Arc 2011-09-02 20:43:59 +02:00
commit 9b20e27c01
3 changed files with 26 additions and 2 deletions

View file

@ -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)]