Skip to content

Commit e21751f

Browse files
committed
Always pop the new frame after a failed call
1 parent d0b41d1 commit e21751f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Python/ceval.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -6410,7 +6410,7 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
64106410
}
64116411
if (initialize_locals(tstate, func, localsarray, args, argcount, kwnames)) {
64126412
assert(frame->owner != FRAME_OWNED_BY_GENERATOR);
6413-
_PyFrame_Clear(frame);
6413+
_PyEvalFrameClearAndPop(tstate, frame);
64146414
return NULL;
64156415
}
64166416
return frame;
@@ -6432,6 +6432,10 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
64326432
static void
64336433
_PyEvalFrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame)
64346434
{
6435+
PyObject **base = (PyObject **)frame;
6436+
// Make sure that this is, indeed, the top frame. We can't check this in
6437+
// _PyThreadState_PopFrame, since f_code is already cleared at that point:
6438+
assert(base + frame->f_code->co_framesize == tstate->datastack_top);
64356439
tstate->recursion_remaining--;
64366440
assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame);
64376441
assert(frame->owner == FRAME_OWNED_BY_THREAD);

0 commit comments

Comments
 (0)