summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-09-02 18:43:59 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2011-09-02 18:43:59 (GMT)
commit9b20e27c01ad995c3950f90dae003437a64f4092 (patch)
tree97cf5118cfdedfe325b124a1a294e91775dcf811 /Lib/ctypes
parent0b6b1c3fb5423bdde5a86284ad2fa98b8b031321 (diff)
parent02dd539dbb2ed51165f4c8138ab16f3498877971 (diff)
downloadcpython-9b20e27c01ad995c3950f90dae003437a64f4092.zip
cpython-9b20e27c01ad995c3950f90dae003437a64f4092.tar.gz
cpython-9b20e27c01ad995c3950f90dae003437a64f4092.tar.bz2
Merge from 3.2: 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.py8
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)]