diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-31 21:36:33 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-31 21:36:33 +0000 |
commit | 54fec8b50a9c6aff3111b013a6205d4434218054 (patch) | |
tree | 93ac2a90429904abca8439f64ec82925a5a861e8 /Lib/ctypes | |
parent | ecdfe16f8f8e896b329c9443264ff68a6dd62727 (diff) | |
download | cpython-54fec8b50a9c6aff3111b013a6205d4434218054.tar.gz |
Merged revisions 88284 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r88284 | antoine.pitrou | 2011-01-31 22:08:57 +0100 (lun., 31 janv. 2011) | 4 lines
Issue #8275: Fix passing of callback arguments with ctypes under Win64.
Patch by Stan Mihai. Ok'ed by Georg.
........
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_callbacks.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py index 0fa2d9dba7..dabcde65c8 100644 --- a/Lib/ctypes/test/test_callbacks.py +++ b/Lib/ctypes/test/test_callbacks.py @@ -166,6 +166,42 @@ class SampleCallbacksTestCase(unittest.TestCase): self.assertLess(diff, 0.01, "%s not less than 0.01" % diff) + def test_callback_register_int(self): + # Issue #8275: buggy handling of callback args under Win64 + # NOTE: should be run on release builds as well + dll = CDLL(_ctypes_test.__file__) + CALLBACK = CFUNCTYPE(c_int, c_int, c_int, c_int, c_int, c_int) + # All this function does is call the callback with its args squared + func = dll._testfunc_cbk_reg_int + func.argtypes = (c_int, c_int, c_int, c_int, c_int, CALLBACK) + func.restype = c_int + + def callback(a, b, c, d, e): + return a + b + c + d + e + + result = func(2, 3, 4, 5, 6, CALLBACK(callback)) + self.assertEqual(result, callback(2*2, 3*3, 4*4, 5*5, 6*6)) + + def test_callback_register_double(self): + # Issue #8275: buggy handling of callback args under Win64 + # NOTE: should be run on release builds as well + dll = CDLL(_ctypes_test.__file__) + CALLBACK = CFUNCTYPE(c_double, c_double, c_double, c_double, + c_double, c_double) + # All this function does is call the callback with its args squared + func = dll._testfunc_cbk_reg_double + func.argtypes = (c_double, c_double, c_double, + c_double, c_double, CALLBACK) + func.restype = c_double + + def callback(a, b, c, d, e): + return a + b + c + d + e + + result = func(1.1, 2.2, 3.3, 4.4, 5.5, CALLBACK(callback)) + self.assertEqual(result, + callback(1.1*1.1, 2.2*2.2, 3.3*3.3, 4.4*4.4, 5.5*5.5)) + + ################################################################ if __name__ == '__main__': |