Index: Lib/test/test_atexit.py =================================================================== --- Lib/test/test_atexit.py (Revision 87703) +++ Lib/test/test_atexit.py (Arbeitskopie) @@ -65,6 +65,14 @@ 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(): Index: Modules/atexitmodule.c =================================================================== --- Modules/atexitmodule.c (Revision 87703) +++ Modules/atexitmodule.c (Arbeitskopie) @@ -72,6 +72,7 @@ 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); } }