Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 176101d

Browse files
committed
correctly rearrange the stack in the exception case of WITH_CLEANUP
1 parent 9e0804f commit 176101d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Python/ceval.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,10 +2533,21 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
25332533
u = v = w = Py_None;
25342534
}
25352535
else {
2536+
PyObject *tp, *exc, *tb;
2537+
PyTryBlock *block;
25362538
v = SECOND();
25372539
w = THIRD();
2540+
tp = FOURTH();
2541+
exc = stack_pointer[-5];
2542+
tb = stack_pointer[-6];
25382543
exit_func = stack_pointer[-7];
2539-
stack_pointer[-7] = NULL;
2544+
stack_pointer[-7] = tb;
2545+
stack_pointer[-6] = exc;
2546+
stack_pointer[-5] = tp;
2547+
FOURTH() = NULL;
2548+
block = &f->f_blockstack[f->f_iblock - 1];
2549+
assert(block->b_type == EXCEPT_HANDLER);
2550+
block->b_level--;
25402551
}
25412552
/* XXX Not the fastest way to call it... */
25422553
x = PyObject_CallFunctionObjArgs(exit_func, u, v, w,

0 commit comments

Comments
 (0)