diff options
author | Thomas Heller <theller@ctypes.org> | 2007-03-09 20:39:22 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2007-03-09 20:39:22 (GMT) |
commit | 2456a3c02aa295c82fc84aaf6d0740d95aeb05b1 (patch) | |
tree | 705702b804d69ab3c1c58c88b3f1ce30b2f70c8f /Lib/ctypes/test | |
parent | e38051db87b92efeb09373bea3900cde073cda96 (diff) | |
download | cpython-2456a3c02aa295c82fc84aaf6d0740d95aeb05b1.zip cpython-2456a3c02aa295c82fc84aaf6d0740d95aeb05b1.tar.gz cpython-2456a3c02aa295c82fc84aaf6d0740d95aeb05b1.tar.bz2 |
Bug #1651235: When a tuple was passed to a ctypes function call,
Python would crash instead of raising an error.
The crash was caused by a section of code that should have been
removed long ago, at that time ctypes had other ways to pass
parameters to function calls.
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_functions.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py index 759aea7..12bd59c 100644 --- a/Lib/ctypes/test/test_functions.py +++ b/Lib/ctypes/test/test_functions.py @@ -21,7 +21,9 @@ if sys.platform == "win32": class POINT(Structure): _fields_ = [("x", c_int), ("y", c_int)] - +class RECT(Structure): + _fields_ = [("left", c_int), ("top", c_int), + ("right", c_int), ("bottom", c_int)] class FunctionTestCase(unittest.TestCase): def test_mro(self): @@ -379,5 +381,15 @@ class FunctionTestCase(unittest.TestCase): self.failUnlessEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h), (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9)) + def test_sf1651235(self): + # see http://www.python.org/sf/1651235 + + proto = CFUNCTYPE(c_int, RECT, POINT) + def callback(*args): + return 0 + + callback = proto(callback) + self.failUnlessRaises(ArgumentError, lambda: callback((1, 2, 3, 4), POINT())) + if __name__ == '__main__': unittest.main() |