diff options
author | Thomas Heller <theller@ctypes.org> | 2007-05-04 07:14:39 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2007-05-04 07:14:39 (GMT) |
commit | 0455214f1cb91027175942c65ac60735322b7645 (patch) | |
tree | 527206717a2d801bf22f4aea331a1a5f0bf80c3a /Lib | |
parent | c0e984002826217c2035573bf11193d0af516117 (diff) | |
download | cpython-0455214f1cb91027175942c65ac60735322b7645.zip cpython-0455214f1cb91027175942c65ac60735322b7645.tar.gz cpython-0455214f1cb91027175942c65ac60735322b7645.tar.bz2 |
Fix some ctypes test crashes, when running with a debug Python
version on win64 by using proper argtypes and restype function
attributes.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_checkretval.py | 2 | ||||
-rw-r--r-- | Lib/ctypes/test/test_python_api.py | 9 | ||||
-rw-r--r-- | Lib/ctypes/test/test_random_things.py | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/Lib/ctypes/test/test_checkretval.py b/Lib/ctypes/test/test_checkretval.py index e055c49..28be6c6 100644 --- a/Lib/ctypes/test/test_checkretval.py +++ b/Lib/ctypes/test/test_checkretval.py @@ -34,7 +34,7 @@ class Test(unittest.TestCase): def test_oledll(self): self.failUnlessRaises(WindowsError, oledll.oleaut32.CreateTypeLib2, - 0, 0, 0) + 0, None, None) if __name__ == "__main__": unittest.main() diff --git a/Lib/ctypes/test/test_python_api.py b/Lib/ctypes/test/test_python_api.py index 9d13474..265ee55 100644 --- a/Lib/ctypes/test/test_python_api.py +++ b/Lib/ctypes/test/test_python_api.py @@ -10,7 +10,10 @@ from _ctypes import PyObj_FromPtr ################################################################ from sys import getrefcount as grc - +if sys.version_info > (2, 4): + c_py_ssize_t = c_size_t +else: + c_py_ssize_t = c_int class PythonAPITestCase(unittest.TestCase): @@ -18,7 +21,7 @@ class PythonAPITestCase(unittest.TestCase): PyString_FromStringAndSize = pythonapi.PyString_FromStringAndSize PyString_FromStringAndSize.restype = py_object - PyString_FromStringAndSize.argtypes = c_char_p, c_int + PyString_FromStringAndSize.argtypes = c_char_p, c_py_ssize_t self.failUnlessEqual(PyString_FromStringAndSize("abcdefghi", 3), "abc") @@ -66,7 +69,7 @@ class PythonAPITestCase(unittest.TestCase): def test_PyOS_snprintf(self): PyOS_snprintf = pythonapi.PyOS_snprintf - PyOS_snprintf.argtypes = POINTER(c_char), c_int, c_char_p + PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p buf = c_buffer(256) PyOS_snprintf(buf, sizeof(buf), "Hello from %s", "ctypes") diff --git a/Lib/ctypes/test/test_random_things.py b/Lib/ctypes/test/test_random_things.py index 78a665b..12b4e62 100644 --- a/Lib/ctypes/test/test_random_things.py +++ b/Lib/ctypes/test/test_random_things.py @@ -13,6 +13,10 @@ if sys.platform == "win32": def test(self): from _ctypes import call_function + windll.kernel32.LoadLibraryA.restype = c_void_p + windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p + windll.kernel32.GetProcAddress.restype = c_void_p + hdll = windll.kernel32.LoadLibraryA("kernel32") funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") |