Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e005dd9

Browse filesBrowse files
authored
bpo-30125: disable faulthandler in ctypes test_SEH (#1237) (#1343)
Disable faulthandler to run test_SEH() of test_ctypes to prevent the following log with a traceback: Windows fatal exception: access violation Add support.disable_faulthandler() context manager. (cherry picked from commit a36e939)
1 parent cb21f5f commit e005dd9
Copy full SHA for e005dd9

File tree

2 files changed

+24
-4
lines changed
Filter options

2 files changed

+24
-4
lines changed

‎Lib/ctypes/test/test_win32.py

Copy file name to clipboardExpand all lines: Lib/ctypes/test/test_win32.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ class FunctionCallTestCase(unittest.TestCase):
4141
@unittest.skipIf(sys.executable.lower().endswith('_d.exe'),
4242
"SEH not enabled in debug builds")
4343
def test_SEH(self):
44-
# Call functions with invalid arguments, and make sure
45-
# that access violations are trapped and raise an
46-
# exception.
47-
self.assertRaises(OSError, windll.kernel32.GetModuleHandleA, 32)
44+
# Disable faulthandler to prevent logging the warning:
45+
# "Windows fatal exception: access violation"
46+
with support.disable_faulthandler():
47+
# Call functions with invalid arguments, and make sure
48+
# that access violations are trapped and raise an
49+
# exception.
50+
self.assertRaises(OSError, windll.kernel32.GetModuleHandleA, 32)
4851

4952
def test_noargs(self):
5053
# This is a special case on win32 x64
5154
windll.user32.GetDesktopWindow()
5255

56+
5357
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
5458
class TestWintypes(unittest.TestCase):
5559
def test_HWND(self):

‎Lib/test/support/__init__.py

Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,3 +2586,19 @@ def setswitchinterval(interval):
25862586
if _is_android_emulator:
25872587
interval = minimum_interval
25882588
return sys.setswitchinterval(interval)
2589+
2590+
2591+
@contextlib.contextmanager
2592+
def disable_faulthandler():
2593+
# use sys.__stderr__ instead of sys.stderr, since regrtest replaces
2594+
# sys.stderr with a StringIO which has no file descriptor when a test
2595+
# is run with -W/--verbose3.
2596+
fd = sys.__stderr__.fileno()
2597+
2598+
is_enabled = faulthandler.is_enabled()
2599+
try:
2600+
faulthandler.disable()
2601+
yield
2602+
finally:
2603+
if is_enabled:
2604+
faulthandler.enable(file=fd, all_threads=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.