summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-10-13 19:53:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-10-13 19:53:13 (GMT)
commit24201d497cf23d399cceadad8058261c13ae536f (patch)
treee4ba7325e0e4e981f910f9e1707a2f5722e0107a /Python
parent4e985673bf29677d243d68cf21884322df3319da (diff)
downloadcpython-24201d497cf23d399cceadad8058261c13ae536f.zip
cpython-24201d497cf23d399cceadad8058261c13ae536f.tar.gz
cpython-24201d497cf23d399cceadad8058261c13ae536f.tar.bz2
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 9ef653b..ee277b6 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1880,6 +1880,16 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
{
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 */
}