diff options
author | Dino Viehland <dinoviehland@meta.com> | 2025-02-26 18:41:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-26 18:41:26 (GMT) |
commit | 5c8e8704c39110da15956b0678303aff7dffb3be (patch) | |
tree | 0ced2ea7f40828bd25d373a2b3ce3cc729627ced /Python/bytecodes.c | |
parent | 9e474a98af4184615540467dea16da05f4d284d8 (diff) | |
download | cpython-5c8e8704c39110da15956b0678303aff7dffb3be.zip cpython-5c8e8704c39110da15956b0678303aff7dffb3be.tar.gz cpython-5c8e8704c39110da15956b0678303aff7dffb3be.tar.bz2 |
gh-130595: Keep traceback alive for WITH_EXCEPT_START (#130562)
Keep traceback alive for WITH_EXCEPT_START
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 6f91b10..9f13095 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3297,13 +3297,10 @@ dummy_func( assert(val_o && PyExceptionInstance_Check(val_o)); exc = PyExceptionInstance_Class(val_o); - tb = PyException_GetTraceback(val_o); + PyObject *original_tb = tb = PyException_GetTraceback(val_o); if (tb == NULL) { tb = Py_None; } - else { - Py_DECREF(tb); - } assert(PyStackRef_LongCheck(lasti)); (void)lasti; // Shut up compiler warning if asserts are off PyObject *stack[5] = {NULL, PyStackRef_AsPyObjectBorrow(exit_self), exc, val_o, tb}; @@ -3311,6 +3308,7 @@ dummy_func( PyObject *res_o = PyObject_Vectorcall(exit_func_o, stack + 2 - has_self, (3 + has_self) | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); ERROR_IF(res_o == NULL, error); + Py_XDECREF(original_tb); res = PyStackRef_FromPyObjectSteal(res_o); } |