[Python-checkins] r55115 - python/trunk/Lib/ctypes/test/test_checkretval.py python/trunk/Lib/ctypes/test/test_python_api.py python/trunk/Lib/ctypes/test/test_random_things.py

thomas.heller python-checkins at python.org
Fri May 4 09:14:40 CEST 2007


Author: thomas.heller
Date: Fri May  4 09:14:39 2007
New Revision: 55115

Modified:
   python/trunk/Lib/ctypes/test/test_checkretval.py
   python/trunk/Lib/ctypes/test/test_python_api.py
   python/trunk/Lib/ctypes/test/test_random_things.py
Log:
Fix some ctypes test crashes, when running with a debug Python
version on win64 by using proper argtypes and restype function
attributes.


Modified: python/trunk/Lib/ctypes/test/test_checkretval.py
==============================================================================
--- python/trunk/Lib/ctypes/test/test_checkretval.py	(original)
+++ python/trunk/Lib/ctypes/test/test_checkretval.py	Fri May  4 09:14:39 2007
@@ -34,7 +34,7 @@
         def test_oledll(self):
             self.failUnlessRaises(WindowsError,
                                   oledll.oleaut32.CreateTypeLib2,
-                                  0, 0, 0)
+                                  0, None, None)
 
 if __name__ == "__main__":
     unittest.main()

Modified: python/trunk/Lib/ctypes/test/test_python_api.py
==============================================================================
--- python/trunk/Lib/ctypes/test/test_python_api.py	(original)
+++ python/trunk/Lib/ctypes/test/test_python_api.py	Fri May  4 09:14:39 2007
@@ -10,7 +10,10 @@
 ################################################################
 
 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 @@
         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 @@
 
     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")

Modified: python/trunk/Lib/ctypes/test/test_random_things.py
==============================================================================
--- python/trunk/Lib/ctypes/test/test_random_things.py	(original)
+++ python/trunk/Lib/ctypes/test/test_random_things.py	Fri May  4 09:14:39 2007
@@ -13,6 +13,10 @@
 
         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")
 


More information about the Python-checkins mailing list