[Python-checkins] r79491 - in python/branches/branch_libffi-3_0_10-win: Lib/ctypes/test/test_win32.py Modules/_ctypes/callproc.c
thomas.heller
python-checkins at python.org
Mon Mar 29 21:30:33 CEST 2010
Author: thomas.heller
Date: Mon Mar 29 21:30:33 2010
New Revision: 79491
Log:
On Windows, ctypes does no longer check the stack before and after
calling a foreign function.
This allows to use the unmodified libffi library.
Modified:
python/branches/branch_libffi-3_0_10-win/Lib/ctypes/test/test_win32.py
python/branches/branch_libffi-3_0_10-win/Modules/_ctypes/callproc.c
Modified: python/branches/branch_libffi-3_0_10-win/Lib/ctypes/test/test_win32.py
==============================================================================
--- python/branches/branch_libffi-3_0_10-win/Lib/ctypes/test/test_win32.py (original)
+++ python/branches/branch_libffi-3_0_10-win/Lib/ctypes/test/test_win32.py Mon Mar 29 21:30:33 2010
@@ -6,32 +6,6 @@
import _ctypes_test
-if sys.platform == "win32" and sizeof(c_void_p) == sizeof(c_int):
- # Only windows 32-bit has different calling conventions.
-
- class WindowsTestCase(unittest.TestCase):
- def test_callconv_1(self):
- # Testing stdcall function
-
- IsWindow = windll.user32.IsWindow
- # ValueError: Procedure probably called with not enough arguments (4 bytes missing)
- self.assertRaises(ValueError, IsWindow)
-
- # This one should succeeed...
- self.assertEqual(0, IsWindow(0))
-
- # ValueError: Procedure probably called with too many arguments (8 bytes in excess)
- self.assertRaises(ValueError, IsWindow, 0, 0, 0)
-
- def test_callconv_2(self):
- # Calling stdcall function as cdecl
-
- IsWindow = cdll.user32.IsWindow
-
- # ValueError: Procedure called with not enough arguments (4 bytes missing)
- # or wrong calling convention
- self.assertRaises(ValueError, IsWindow, None)
-
if sys.platform == "win32":
class FunctionCallTestCase(unittest.TestCase):
Modified: python/branches/branch_libffi-3_0_10-win/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/branch_libffi-3_0_10-win/Modules/_ctypes/callproc.c (original)
+++ python/branches/branch_libffi-3_0_10-win/Modules/_ctypes/callproc.c Mon Mar 29 21:30:33 2010
@@ -756,7 +756,6 @@
ffi_cif cif;
int cc;
#ifdef MS_WIN32
- int delta;
#ifndef DONT_USE_SEH
DWORD dwExceptionCode = 0;
EXCEPTION_RECORD record;
@@ -807,13 +806,8 @@
#ifndef DONT_USE_SEH
__try {
#endif
-/*
- XXX THIS CODE MUST BE ENABLED LATER AGAIN, AFTER libffi is patched for X86_WIN32!
- delta =
-*/
- delta = 0;
#endif
- ffi_call(&cif, (void *)pProc, resmem, avalues);
+ ffi_call(&cif, (void *)pProc, resmem, avalues);
#ifdef MS_WIN32
#ifndef DONT_USE_SEH
}
@@ -845,35 +839,6 @@
return -1;
}
#endif
-#ifdef MS_WIN64
- if (delta != 0) {
- PyErr_Format(PyExc_RuntimeError,
- "ffi_call failed with code %d",
- delta);
- return -1;
- }
-#else
- if (delta < 0) {
- if (flags & FUNCFLAG_CDECL)
- PyErr_Format(PyExc_ValueError,
- "Procedure called with not enough "
- "arguments (%d bytes missing) "
- "or wrong calling convention",
- -delta);
- else
- PyErr_Format(PyExc_ValueError,
- "Procedure probably called with not enough "
- "arguments (%d bytes missing)",
- -delta);
- return -1;
- } else if (delta > 0) {
- PyErr_Format(PyExc_ValueError,
- "Procedure probably called with too many "
- "arguments (%d bytes in excess)",
- delta);
- return -1;
- }
-#endif
#endif
if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred())
return -1;
More information about the Python-checkins
mailing list