]> granicus.if.org Git - python/commitdiff
Fix for a bug found by Armin Rigo, plus test.
authorThomas Heller <theller@ctypes.org>
Wed, 12 Apr 2006 19:07:36 +0000 (19:07 +0000)
committerThomas Heller <theller@ctypes.org>
Wed, 12 Apr 2006 19:07:36 +0000 (19:07 +0000)
https://sourceforge.net/tracker/?func=detail&atid=532154&aid=1467852&group_id=71702

Lib/ctypes/test/test_pointers.py
Modules/_ctypes/_ctypes.c

index 6172abb1f63297371089f19776d280eca8017ca4..3a324a67c34591d2f4072ecf5a35b36cfaf4b021 100644 (file)
@@ -166,6 +166,18 @@ class PointersTestCase(unittest.TestCase):
         result = func( byref(argc), argv )
         assert result == 'world', result
 
+    def test_bug_1467852(self):
+        # http://sourceforge.net/tracker/?func=detail&atid=532154&aid=1467852&group_id=71702
+        x = c_int(5)
+        dummy = []
+        for i in range(32000):
+            dummy.append(c_int(i))
+        y = c_int(6)
+        p = pointer(x)
+        pp = pointer(p)
+        q = pointer(y)
+        pp[0] = q         # <==
+        self.failUnlessEqual(p[0], 6)
 
 if __name__ == '__main__':
     unittest.main()
index bcb179ee82e34fbbb162c14e08e424fa2ba18609..d751841095cbda6746959861b5d6b2e689be9550 100644 (file)
@@ -548,7 +548,7 @@ PointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                return NULL;
        stgdict->size = sizeof(void *);
        stgdict->align = getentry("P")->pffi_type->alignment;
-       stgdict->length = 2;
+       stgdict->length = 1;
        stgdict->ffi_type = ffi_type_pointer;
 
        proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */