Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 86333:c13ef65f3dcf
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Sun, 13 Oct 2013 21:54:15 +0200 |
| parents | c7fdb0637d0b 19ce90930e8b |
| children | 9cd88b39ef62 |
line wrap: on
line diff
--- a/Python/pythonrun.c Sun Oct 13 21:49:06 2013 +0200 +++ b/Python/pythonrun.c Sun Oct 13 21:54:15 2013 +0200 @@ -1919,6 +1919,16 @@ { PyObject *seen; PyObject *f = PySys_GetObject("stderr"); + if (PyExceptionInstance_Check(value) + && tb != NULL && PyTraceBack_Check(tb)) { + /* Put the traceback on the exception, otherwise it won't get + displayed. See issue #18776. */ + PyObject *cur_tb = PyException_GetTraceback(value); + if (cur_tb == NULL) + PyException_SetTraceback(value, tb); + else + Py_DECREF(cur_tb); + } if (f == Py_None) { /* pass */ }
