[Python-checkins] cpython (merge 3.2 -> default): merge 3.2

benjamin.peterson python-checkins at python.org
Thu Jul 14 06:06:31 CEST 2011


http://hg.python.org/cpython/rev/f45823977d4b
changeset:   71321:f45823977d4b
parent:      71319:dd004e85e299
parent:      71320:b82237a29824
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Jul 13 23:11:14 2011 -0500
summary:
  merge 3.2

files:
  Lib/ctypes/test/test_byteswap.py |  24 ++++++++++----------
  1 files changed, 12 insertions(+), 12 deletions(-)


diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -1,4 +1,4 @@
-import sys, unittest, struct, math
+import sys, unittest, struct, math, ctypes
 from binascii import hexlify
 
 from ctypes import *
@@ -188,16 +188,6 @@
         # nested structures with different byteorders
 
         # create nested structures with given byteorders and set memory to data
-        def set_structures(endianness, nested_endianness, data):
-            class NestedStructure(nested_endianness):
-                _fields_ = [("x", c_uint32),
-                            ("y", c_uint32)]
-
-            class TestStructure(endianness):
-                _fields_ = [("point", NestedStructure)]
-
-            self.assertEqual(len(data), sizeof(TestStructure))
-            return cast(data, POINTER(TestStructure))[0]
 
         for nested, data in (
             (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
@@ -208,7 +198,17 @@
                 LittleEndianStructure,
                 Structure,
             ):
-                s = set_structures(parent, nested, data)
+                class NestedStructure(nested):
+                    _fields_ = [("x", c_uint32),
+                                ("y", c_uint32)]
+
+                class TestStructure(parent):
+                    _fields_ = [("point", NestedStructure)]
+
+                self.assertEqual(len(data), sizeof(TestStructure))
+                ptr = POINTER(TestStructure)
+                s = cast(data, ptr)[0]
+                del ctypes._pointer_type_cache[TestStructure]
                 self.assertEqual(s.point.x, 1)
                 self.assertEqual(s.point.y, 2)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list