mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
commit
9b20e27c01
3 changed files with 26 additions and 2 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue