Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d77e2ea

Browse files
committed
merge 3.2
2 parents bf9c021 + 6e18e04 commit d77e2ea

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Lib/ctypes/test/test_byteswap.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys, unittest, struct, math
1+
import sys, unittest, struct, math, ctypes
22
from binascii import hexlify
33

44
from ctypes import *
@@ -188,16 +188,6 @@ def test_struct_struct(self):
188188
# nested structures with different byteorders
189189

190190
# create nested structures with given byteorders and set memory to data
191-
def set_structures(endianness, nested_endianness, data):
192-
class NestedStructure(nested_endianness):
193-
_fields_ = [("x", c_uint32),
194-
("y", c_uint32)]
195-
196-
class TestStructure(endianness):
197-
_fields_ = [("point", NestedStructure)]
198-
199-
self.assertEqual(len(data), sizeof(TestStructure))
200-
return cast(data, POINTER(TestStructure))[0]
201191

202192
for nested, data in (
203193
(BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
@@ -208,7 +198,17 @@ class TestStructure(endianness):
208198
LittleEndianStructure,
209199
Structure,
210200
):
211-
s = set_structures(parent, nested, data)
201+
class NestedStructure(nested):
202+
_fields_ = [("x", c_uint32),
203+
("y", c_uint32)]
204+
205+
class TestStructure(parent):
206+
_fields_ = [("point", NestedStructure)]
207+
208+
self.assertEqual(len(data), sizeof(TestStructure))
209+
ptr = POINTER(TestStructure)
210+
s = cast(data, ptr)[0]
211+
del ctypes._pointer_type_cache[TestStructure]
212212
self.assertEqual(s.point.x, 1)
213213
self.assertEqual(s.point.y, 2)
214214

0 commit comments

Comments
 (0)