diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 13:20:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 13:20:43 (GMT) |
commit | b0426cd8c4ecaa19cff05b4860da1c06531a77c1 (patch) | |
tree | 6dfb0cc68042324906e1d2738f5d6b6e8ab6a522 /Python/errors.c | |
parent | 0a421a28f87f2a01566e443fc59203d0b7bcb3b8 (diff) | |
parent | 9e373be1bc56f69c5af4124db014447eb394970c (diff) | |
download | cpython-b0426cd8c4ecaa19cff05b4860da1c06531a77c1.zip cpython-b0426cd8c4ecaa19cff05b4860da1c06531a77c1.tar.gz cpython-b0426cd8c4ecaa19cff05b4860da1c06531a77c1.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 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); |