diff options
Diffstat (limited to 'Lib/test/libregrtest/utils.py')
-rw-r--r-- | Lib/test/libregrtest/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index fb9971a64f..2691a2c30c 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -2,6 +2,7 @@ import math import os.path import sys import textwrap +from test import support def format_duration(seconds): @@ -59,3 +60,19 @@ def printlist(x, width=70, indent=4, file=None): def print_warning(msg): print(f"Warning -- {msg}", file=sys.stderr, flush=True) + + +orig_unraisablehook = None + + +def regrtest_unraisable_hook(unraisable): + global orig_unraisablehook + support.environment_altered = True + print_warning("Unraisable exception") + orig_unraisablehook(unraisable) + + +def setup_unraisable_hook(): + global orig_unraisablehook + orig_unraisablehook = sys.unraisablehook + sys.unraisablehook = regrtest_unraisable_hook |