diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-04-21 22:31:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-21 22:31:13 (GMT) |
commit | a36e939aeb3b5a2c56561eb24f0e339eee9f3f9d (patch) | |
tree | b4f48eac59cb7cf7ef3446d78bf2cfe637307570 /Lib/test/support/__init__.py | |
parent | ae5b3260dd459845aad8a30491b76d471577785d (diff) | |
download | cpython-a36e939aeb3b5a2c56561eb24f0e339eee9f3f9d.zip cpython-a36e939aeb3b5a2c56561eb24f0e339eee9f3f9d.tar.gz cpython-a36e939aeb3b5a2c56561eb24f0e339eee9f3f9d.tar.bz2 |
bpo-30125: disable faulthandler in ctypes test_SEH (#1237)
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.
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r-- | Lib/test/support/__init__.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d3beef2..56b6b07 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -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) |