Issue #10756: atexit normalizes the exception before displaying it. Patch by

Andreas Stührk.

Backport a fix already applied to Python 3.2+ (4a82be47a948 + 5060a92a8597).
This commit is contained in:
Victor Stinner 2011-05-15 18:57:44 +02:00
parent 2ec6b176bd
commit d0e11ec5b0
3 changed files with 12 additions and 0 deletions

View File

@ -65,6 +65,14 @@ class TestCase(unittest.TestCase):
self.assertRaises(TypeError, atexit._run_exitfuncs)
def test_raise_unnormalized(self):
# Issue #10756: Make sure that an unnormalized exception is
# handled properly
atexit.register(lambda: 1 / 0)
self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
self.assertIn("ZeroDivisionError", self.stream.getvalue())
def test_stress(self):
a = [0]
def inc():

View File

@ -72,6 +72,9 @@ Core and Builtins
Library
-------
- Issue #10756: atexit normalizes the exception before displaying it. Patch by
Andreas Stührk.
- Issue #8650: Make zlib module 64-bit clean. compress(), decompress() and
their incremental counterparts now raise OverflowError if given an input
larger than 4GB, instead of silently truncating the input and returning

View File

@ -72,6 +72,7 @@ atexit_callfuncs(void)
PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
if (!PyErr_ExceptionMatches(PyExc_SystemExit)) {
PySys_WriteStderr("Error in atexit._run_exitfuncs:\n");
PyErr_NormalizeException(&exc_type, &exc_value, &exc_tb);
PyErr_Display(exc_type, exc_value, exc_tb);
}
}