diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-22 23:00:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 23:00:58 (GMT) |
commit | df22c03b93ea4620fdf4a0b3cbbbfa7c645af783 (patch) | |
tree | 87a86340ef143d19350e9f52b18d4f28f0a982b7 /Lib | |
parent | 5edcf263581c70f6a6c2206db679e51e9418bb38 (diff) | |
download | cpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.zip cpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.tar.gz cpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.tar.bz2 |
bpo-36829: PyErr_WriteUnraisable() normalizes exception (GH-13507)
PyErr_WriteUnraisable() now creates a traceback object if there is no
current traceback. Moreover, call PyErr_NormalizeException() and
PyException_SetTraceback() to normalize the exception value. Ignore
silently any error.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sys.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 67a952d..1e5f168 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -882,19 +882,14 @@ class UnraisableHookTest(unittest.TestCase): import _testcapi import types try: - # raise the exception to get a traceback in the except block - try: - raise exc - except Exception as exc2: - _testcapi.write_unraisable_exc(exc2, obj) - return types.SimpleNamespace(exc_type=type(exc2), - exc_value=exc2, - exc_traceback=exc2.__traceback__, - object=obj) + _testcapi.write_unraisable_exc(exc, obj) + return types.SimpleNamespace(exc_type=type(exc), + exc_value=exc, + exc_traceback=exc.__traceback__, + object=obj) finally: # Explicitly break any reference cycle exc = None - exc2 = None def test_original_unraisablehook(self): obj = "an object" |