diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2014-01-26 14:53:38 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2014-01-26 14:53:38 (GMT) |
commit | 77b286b2ccccc407d8ed17b0543b10f7c1ccc864 (patch) | |
tree | 2e95a1c03b79829ebf72698d61da997f501ef1a5 /Objects | |
parent | 23e37aa7b787fd41623c4f3f1eb7ca16ded2ef96 (diff) | |
download | cpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.zip cpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.tar.gz cpython-77b286b2ccccc407d8ed17b0543b10f7c1ccc864.tar.bz2 |
Close #20105: set __traceback__ when chaining exceptions in C
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/exceptions.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index bff7f08..2531ead 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -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); |