diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 13:19:59 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 13:19:59 (GMT) |
commit | 9e373be1bc56f69c5af4124db014447eb394970c (patch) | |
tree | 0bd0e2c8e408d7126dffb1b714756b740c958d4f /Python/errors.c | |
parent | f536af1fcdfaa81350be5a0a043f7230ed5d8049 (diff) | |
download | cpython-9e373be1bc56f69c5af4124db014447eb394970c.zip cpython-9e373be1bc56f69c5af4124db014447eb394970c.tar.gz cpython-9e373be1bc56f69c5af4124db014447eb394970c.tar.bz2 |
Issue #28410: Keep the traceback of original exception in _PyErr_ChainExceptions().
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c index e151cab..6cc0c20 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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); |