Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 667ce06

Browse files
author
Thomas Heller
committed
Merged revisions 80761,80766 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r80761 | thomas.heller | 2010-05-04 20:44:42 +0200 (Di, 04 Mai 2010) | 8 lines On Windows, ctypes does no longer check the stack before and after calling a foreign function. This allows to use the unmodified libffi library. Remove most files from _ctypes/libffi_msvc, only two include files stay (updated from _ctypes/libffi/...). Other files are used in the cross-platform _ctypes/libffi directory. ........ r80766 | thomas.heller | 2010-05-04 21:08:18 +0200 (Di, 04 Mai 2010) | 2 lines Remove reference to unused source file. ........
1 parent a9eb87a commit 667ce06

15 files changed

Lines changed: 376 additions & 1951 deletions

File tree

Lib/ctypes/test/test_win32.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66

77
import _ctypes_test
88

9-
if sys.platform == "win32" and sizeof(c_void_p) == sizeof(c_int):
10-
# Only windows 32-bit has different calling conventions.
11-
12-
class WindowsTestCase(unittest.TestCase):
13-
def test_callconv_1(self):
14-
# Testing stdcall function
15-
16-
IsWindow = windll.user32.IsWindow
17-
# ValueError: Procedure probably called with not enough arguments (4 bytes missing)
18-
self.assertRaises(ValueError, IsWindow)
19-
20-
# This one should succeeed...
21-
self.assertEqual(0, IsWindow(0))
22-
23-
# ValueError: Procedure probably called with too many arguments (8 bytes in excess)
24-
self.assertRaises(ValueError, IsWindow, 0, 0, 0)
25-
26-
def test_callconv_2(self):
27-
# Calling stdcall function as cdecl
28-
29-
IsWindow = cdll.user32.IsWindow
30-
31-
# ValueError: Procedure called with not enough arguments (4 bytes missing)
32-
# or wrong calling convention
33-
self.assertRaises(ValueError, IsWindow, None)
34-
359
if sys.platform == "win32":
3610
class FunctionCallTestCase(unittest.TestCase):
3711

Modules/_ctypes/callproc.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,6 @@ static int _call_function_pointer(int flags,
761761
ffi_cif cif;
762762
int cc;
763763
#ifdef MS_WIN32
764-
int delta;
765764
#ifndef DONT_USE_SEH
766765
DWORD dwExceptionCode = 0;
767766
EXCEPTION_RECORD record;
@@ -812,9 +811,8 @@ static int _call_function_pointer(int flags,
812811
#ifndef DONT_USE_SEH
813812
__try {
814813
#endif
815-
delta =
816814
#endif
817-
ffi_call(&cif, (void *)pProc, resmem, avalues);
815+
ffi_call(&cif, (void *)pProc, resmem, avalues);
818816
#ifdef MS_WIN32
819817
#ifndef DONT_USE_SEH
820818
}
@@ -846,35 +844,6 @@ static int _call_function_pointer(int flags,
846844
return -1;
847845
}
848846
#endif
849-
#ifdef MS_WIN64
850-
if (delta != 0) {
851-
PyErr_Format(PyExc_RuntimeError,
852-
"ffi_call failed with code %d",
853-
delta);
854-
return -1;
855-
}
856-
#else
857-
if (delta < 0) {
858-
if (flags & FUNCFLAG_CDECL)
859-
PyErr_Format(PyExc_ValueError,
860-
"Procedure called with not enough "
861-
"arguments (%d bytes missing) "
862-
"or wrong calling convention",
863-
-delta);
864-
else
865-
PyErr_Format(PyExc_ValueError,
866-
"Procedure probably called with not enough "
867-
"arguments (%d bytes missing)",
868-
-delta);
869-
return -1;
870-
} else if (delta > 0) {
871-
PyErr_Format(PyExc_ValueError,
872-
"Procedure probably called with too many "
873-
"arguments (%d bytes in excess)",
874-
delta);
875-
return -1;
876-
}
877-
#endif
878847
#endif
879848
if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred())
880849
return -1;
@@ -1147,11 +1116,7 @@ PyObject *_ctypes_callproc(PPROC pProc,
11471116
}
11481117
for (i = 0; i < argcount; ++i) {
11491118
atypes[i] = args[i].ffi_type;
1150-
if (atypes[i]->type == FFI_TYPE_STRUCT
1151-
#ifdef _WIN64
1152-
&& atypes[i]->size <= sizeof(void *)
1153-
#endif
1154-
)
1119+
if (atypes[i]->type == FFI_TYPE_STRUCT)
11551120
avalues[i] = (void *)args[i].value.p;
11561121
else
11571122
avalues[i] = (void *)&args[i].value;

Modules/_ctypes/libffi_msvc/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)