diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-09 01:52:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-09 01:52:26 (GMT) |
commit | 8a285df806816805484fed36dce5fd5b77a215a6 (patch) | |
tree | 1316ddfdbdeb547a7964106ac5f3a432bb957687 /Python | |
parent | 4bed0db7c222f8df1b4e31107c0305214caf3f56 (diff) | |
download | cpython-8a285df806816805484fed36dce5fd5b77a215a6.zip cpython-8a285df806816805484fed36dce5fd5b77a215a6.tar.gz cpython-8a285df806816805484fed36dce5fd5b77a215a6.tar.bz2 |
GH-93252: Fix error handling for failed Python calls (GH-94693)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 0176002..2a0ce63 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -6410,7 +6410,7 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func, } if (initialize_locals(tstate, func, localsarray, args, argcount, kwnames)) { assert(frame->owner != FRAME_OWNED_BY_GENERATOR); - _PyFrame_Clear(frame); + _PyEvalFrameClearAndPop(tstate, frame); return NULL; } return frame; @@ -6432,6 +6432,10 @@ fail: static void _PyEvalFrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame) { + // Make sure that this is, indeed, the top frame. We can't check this in + // _PyThreadState_PopFrame, since f_code is already cleared at that point: + assert((PyObject **)frame + frame->f_code->co_framesize == + tstate->datastack_top); tstate->recursion_remaining--; assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame); assert(frame->owner == FRAME_OWNED_BY_THREAD); |