]> granicus.if.org Git - python/commitdiff
Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions().
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 21 Oct 2016 13:19:59 +0000 (16:19 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 21 Oct 2016 13:19:59 +0000 (16:19 +0300)
Python/errors.c

index e151cab17cb56be1a38b9d5af46fa86adcf7083d..6cc0c20cd55dde62303e3dc97c6fec00d06d2260 100644 (file)
@@ -388,8 +388,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);