Close #20105: set __traceback__ when chaining exceptions in C

This commit is contained in:
Nick Coghlan 2014-01-27 00:53:38 +10:00
parent 23e37aa7b7
commit 77b286b2cc
5 changed files with 27 additions and 2 deletions

View file

@ -2689,8 +2689,11 @@ _PyErr_TrySetFromCause(const char *format, ...)
* types as well, but that's quite a bit trickier due to the extra
* state potentially stored on OSError instances.
*/
Py_XDECREF(tb);
/* Ensure the traceback is set correctly on the existing exception */
if (tb != NULL) {
PyException_SetTraceback(val, tb);
Py_DECREF(tb);
}
#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, format);