diff -r 86af5991c809 Modules/atexitmodule.c --- a/Modules/atexitmodule.c Sun Oct 13 20:56:25 2013 +0200 +++ b/Modules/atexitmodule.c Sun Oct 13 21:24:14 2013 +0200 @@ -100,6 +100,9 @@ atexit_callfuncs(void) if (!PyErr_ExceptionMatches(PyExc_SystemExit)) { PySys_WriteStderr("Error in atexit._run_exitfuncs:\n"); PyErr_NormalizeException(&exc_type, &exc_value, &exc_tb); + /* PyErr_Display disregards the traceback argument, it must be + given as an attribute of the exception value object. */ + PyException_SetTraceback(exc_value, exc_tb); PyErr_Display(exc_type, exc_value, exc_tb); } } diff -r 86af5991c809 Python/pythonrun.c --- a/Python/pythonrun.c Sun Oct 13 20:56:25 2013 +0200 +++ b/Python/pythonrun.c Sun Oct 13 21:24:14 2013 +0200 @@ -1730,6 +1730,7 @@ PyErr_PrintEx(int set_sys_last_vars) v2 = Py_None; Py_INCREF(v2); } + PyException_SetTraceback(v2, tb2); fflush(stdout); PySys_WriteStderr("Error in sys.excepthook:\n"); PyErr_Display(exception2, v2, tb2);