summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Python/errors.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 13ae6b4..12bde28 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -387,8 +387,11 @@ _PyErr_ChainExceptions(PyObject *exc, PyObject *val, PyObject *tb)
PyObject *exc2, *val2, *tb2;
PyErr_Fetch(&exc2, &val2, &tb2);
PyErr_NormalizeException(&exc, &val, &tb);
+ if (tb != NULL) {
+ PyException_SetTraceback(val, tb);
+ Py_DECREF(tb);
+ }
Py_DECREF(exc);
- Py_XDECREF(tb);
PyErr_NormalizeException(&exc2, &val2, &tb2);
PyException_SetContext(val2, val);
PyErr_Restore(exc2, val2, tb2);