Kaydet (Commit) 43d9a58d authored tarafından Thomas Heller's avatar Thomas Heller

Revert the change done in svn revision 47206:

Add a new function uses_seh() to the _ctypes extension module.  This
will return True if Windows Structured Exception handling (SEH) is
used when calling functions, False otherwise.
üst 4cbd05c3
...@@ -30,11 +30,15 @@ if sys.platform == "win32": ...@@ -30,11 +30,15 @@ if sys.platform == "win32":
# or wrong calling convention # or wrong calling convention
self.assertRaises(ValueError, IsWindow, None) self.assertRaises(ValueError, IsWindow, None)
import _ctypes def test_SEH(self):
if _ctypes.uses_seh(): # Call functions with invalid arguments, and make sure that access violations
def test_SEH(self): # are trapped and raise an exception.
# Call functions with invalid arguments, and make sure that access violations #
# are trapped and raise an exception. # Normally, in a debug build of the _ctypes extension
# module, exceptions are not trapped, so we can only run
# this test in a release build.
import sys
if not hasattr(sys, "getobjects"):
self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32) self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
class Structures(unittest.TestCase): class Structures(unittest.TestCase):
......
...@@ -1526,21 +1526,7 @@ resize(PyObject *self, PyObject *args) ...@@ -1526,21 +1526,7 @@ resize(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
static PyObject *
uses_seh(PyObject *self, PyObject *args)
{
#if defined(DONT_USE_SEH) || !defined(MS_WIN32)
Py_INCREF(Py_False);
return Py_False;
#else
Py_INCREF(Py_True);
return Py_True;
#endif
}
PyMethodDef module_methods[] = { PyMethodDef module_methods[] = {
{"uses_seh", uses_seh, METH_NOARGS,
"Return whether ctypes uses Windows structured exception handling"},
{"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"}, {"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"},
#ifdef CTYPES_UNICODE #ifdef CTYPES_UNICODE
{"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc}, {"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment