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

bpo-30125: disable faulthandler in ctypes test_SEH #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-30125: disable faulthandler in ctypes test_SEH
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.
  • Loading branch information
vstinner committed Apr 21, 2017
commit 25cef3e489d1dd0883d121e5b27d7850fc1e21e1
12 changes: 8 additions & 4 deletions 12 Lib/ctypes/test/test_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ class FunctionCallTestCase(unittest.TestCase):
@unittest.skipIf(sys.executable.lower().endswith('_d.exe'),
"SEH not enabled in debug builds")
def test_SEH(self):
# Call functions with invalid arguments, and make sure
# that access violations are trapped and raise an
# exception.
self.assertRaises(OSError, windll.kernel32.GetModuleHandleA, 32)
# Disable faulthandler to prevent logging the warning:
# "Windows fatal exception: access violation"
with support.disable_faulthandler():
# Call functions with invalid arguments, and make sure
# that access violations are trapped and raise an
# exception.
self.assertRaises(OSError, windll.kernel32.GetModuleHandleA, 32)

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


@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
class TestWintypes(unittest.TestCase):
def test_HWND(self):
Expand Down
16 changes: 16 additions & 0 deletions 16 Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2595,3 +2595,19 @@ def setswitchinterval(interval):
if _is_android_emulator:
interval = minimum_interval
return sys.setswitchinterval(interval)


@contextlib.contextmanager
def disable_faulthandler():
# use sys.__stderr__ instead of sys.stderr, since regrtest replaces
# sys.stderr with a StringIO which has no file descriptor when a test
# is run with -W/--verbose3.
fd = sys.__stderr__.fileno()

is_enabled = faulthandler.is_enabled()
try:
faulthandler.disable()
yield
finally:
if is_enabled:
faulthandler.enable(file=fd, all_threads=True)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.