Skip to content

Commit dec4ef9

Browse files
committed
Keep traceback alive for WITH_EXCEPT_START
1 parent 0ef4ffe commit dec4ef9

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

Python/bytecodes.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -3297,20 +3297,18 @@ dummy_func(
32973297

32983298
assert(val_o && PyExceptionInstance_Check(val_o));
32993299
exc = PyExceptionInstance_Class(val_o);
3300-
tb = PyException_GetTraceback(val_o);
3300+
PyObject *original_tb = tb = PyException_GetTraceback(val_o);
33013301
if (tb == NULL) {
33023302
tb = Py_None;
33033303
}
3304-
else {
3305-
Py_DECREF(tb);
3306-
}
33073304
assert(PyStackRef_LongCheck(lasti));
33083305
(void)lasti; // Shut up compiler warning if asserts are off
33093306
PyObject *stack[5] = {NULL, PyStackRef_AsPyObjectBorrow(exit_self), exc, val_o, tb};
33103307
int has_self = !PyStackRef_IsNull(exit_self);
33113308
PyObject *res_o = PyObject_Vectorcall(exit_func_o, stack + 2 - has_self,
33123309
(3 + has_self) | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
33133310
ERROR_IF(res_o == NULL, error);
3311+
Py_XDECREF(original_tb);
33143312
res = PyStackRef_FromPyObjectSteal(res_o);
33153313
}
33163314

Python/executor_cases.c.h

+4-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

+4-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)