summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-05-17 21:57:10 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-05-17 21:57:10 (GMT)
commitd3d23636cbb2fb305f672fa826c3da6a2dc72384 (patch)
treefec57d71cccdf03f8e416802261abcac7ada01ee /Lib
parentc2a66f20eaf6d28825cca9f3b55a3fa33fbd87b3 (diff)
downloadcpython-d3d23636cbb2fb305f672fa826c3da6a2dc72384.zip
cpython-d3d23636cbb2fb305f672fa826c3da6a2dc72384.tar.gz
cpython-d3d23636cbb2fb305f672fa826c3da6a2dc72384.tar.bz2
support pep 3118 format strings for ctypes objects with nontrivial shapes (closes #10744)
Patch from Matti Picus.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_pep3118.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/ctypes/test/test_pep3118.py b/Lib/ctypes/test/test_pep3118.py
index 976473c..3e007e1 100644
--- a/Lib/ctypes/test/test_pep3118.py
+++ b/Lib/ctypes/test/test_pep3118.py
@@ -92,6 +92,10 @@ class EmptyStruct(Structure):
class aUnion(Union):
_fields_ = [("a", c_int)]
+class StructWithArrays(Structure):
+ _fields_ = [("x", c_long * 3 * 2), ("y", Point * 4)]
+
+
class Incomplete(Structure):
pass
@@ -141,10 +145,10 @@ native_types = [
## arrays and pointers
- (c_double * 4, "(4)<d", (4,), c_double),
- (c_float * 4 * 3 * 2, "(2,3,4)<f", (2,3,4), c_float),
- (POINTER(c_short) * 2, "(2)&<h", (2,), POINTER(c_short)),
- (POINTER(c_short) * 2 * 3, "(3,2)&<h", (3,2,), POINTER(c_short)),
+ (c_double * 4, "<d", (4,), c_double),
+ (c_float * 4 * 3 * 2, "<f", (2,3,4), c_float),
+ (POINTER(c_short) * 2, "&<h", (2,), POINTER(c_short)),
+ (POINTER(c_short) * 2 * 3, "&<h", (3,2,), POINTER(c_short)),
(POINTER(c_short * 2), "&(2)<h", None, POINTER(c_short)),
## structures and unions
@@ -156,6 +160,9 @@ native_types = [
(EmptyStruct, "T{}", None, EmptyStruct),
# the pep does't support unions
(aUnion, "B", None, aUnion),
+ # structure with sub-arrays
+ (StructWithArrays, "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}", None, StructWithArrays),
+ (StructWithArrays * 3, "T{(2,3)<l:x:(4)T{<l:x:<l:y:}:y:}", (3,), StructWithArrays),
## pointer to incomplete structure
(Incomplete, "B", None, Incomplete),