diff options
author | Thomas Heller <theller@ctypes.org> | 2006-07-03 08:08:14 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2006-07-03 08:08:14 (GMT) |
commit | f780be4239817192a93c34b768f6565aee8c2130 (patch) | |
tree | 61c0d37eaa3af547d62e98126be3fbf5666f2f69 /Modules | |
parent | 638f7addf39afe167aab84521202a54d1cd42587 (diff) | |
download | cpython-f780be4239817192a93c34b768f6565aee8c2130.zip cpython-f780be4239817192a93c34b768f6565aee8c2130.tar.gz cpython-f780be4239817192a93c34b768f6565aee8c2130.tar.bz2 |
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.
Currently, only MSVC supports SEH.
Fix the test so that it doesn't crash when run with MingW compiled
_ctypes. Note that two tests are still failing when mingw is used, I
suspect structure layout differences and function calling conventions
between MSVC and MingW.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 16e10de..4ec1f13 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1526,7 +1526,21 @@ resize(PyObject *self, PyObject *args) 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[] = { + {"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"}, #ifdef CTYPES_UNICODE {"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc}, |