summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-07-03 08:08:14 (GMT)
committerThomas Heller <theller@ctypes.org>2006-07-03 08:08:14 (GMT)
commitf780be4239817192a93c34b768f6565aee8c2130 (patch)
tree61c0d37eaa3af547d62e98126be3fbf5666f2f69 /Lib/ctypes
parent638f7addf39afe167aab84521202a54d1cd42587 (diff)
downloadcpython-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 'Lib/ctypes')
-rw-r--r--Lib/ctypes/test/test_win32.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index 8247d37..eb016ff 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -30,15 +30,11 @@ if sys.platform == "win32":
# or wrong calling convention
self.assertRaises(ValueError, IsWindow, None)
- def test_SEH(self):
- # 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"):
+ import _ctypes
+ if _ctypes.uses_seh():
+ def test_SEH(self):
+ # Call functions with invalid arguments, and make sure that access violations
+ # are trapped and raise an exception.
self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
class Structures(unittest.TestCase):