summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-10-13 21:54:15 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-10-13 21:54:15 +0200
commit52c962ffacbf51812028f991939c36918062e94f (patch)
treea0b085b5adf9a7c7368fe201695e9d06fc6d6d08 /Python/pythonrun.c
parent51ec371f8d16c26f1c4792c79aefc8497dabe113 (diff)
parenta5b3af7156594cc0a7964ac808f7807970912c8e (diff)
downloadcpython-52c962ffacbf51812028f991939c36918062e94f.tar.gz
Issue #18776: atexit callbacks now display their full traceback when they raise an exception.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index c2ca563d1a..06f30b0f40 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1919,6 +1919,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 */
}