diff options
author | Thomas Heller <theller@ctypes.org> | 2006-07-10 09:10:28 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2006-07-10 09:10:28 (GMT) |
commit | dda068dee1937d0dd144568a83e2a47e5c26f9a2 (patch) | |
tree | c9d34a4afc654d7cb4041bb35f98eb0a6ae2d0bb /Lib | |
parent | 70e8e877509d643150ed6fd27bce29523f169690 (diff) | |
download | cpython-dda068dee1937d0dd144568a83e2a47e5c26f9a2.zip cpython-dda068dee1937d0dd144568a83e2a47e5c26f9a2.tar.gz cpython-dda068dee1937d0dd144568a83e2a47e5c26f9a2.tar.bz2 |
Fix bug #1518190: accept any integer or long value in the
ctypes.c_void_p constructor.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_pointers.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py index a7a2802..586655a 100644 --- a/Lib/ctypes/test/test_pointers.py +++ b/Lib/ctypes/test/test_pointers.py @@ -157,6 +157,23 @@ class PointersTestCase(unittest.TestCase): q = pointer(y) pp[0] = q # <== self.failUnlessEqual(p[0], 6) + def test_c_void_p(self): + # http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=105470 + if sizeof(c_void_p) == 4: + self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value, + c_void_p(-1).value) + self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value, + c_void_p(-1).value) + elif sizeof(c_void_p) == 8: + self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value, + 0xFFFFFFFFL) + self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value, + c_void_p(-1).value) + self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFFL).value, + c_void_p(-1).value) + + self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted + self.assertRaises(TypeError, c_void_p, object()) # nor other objects if __name__ == '__main__': unittest.main() |