summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-07-09 12:09:15 (GMT)
committerGitHub <noreply@github.com>2022-07-09 12:09:15 (GMT)
commit7a341724e4dc8188f01ac338deaa414c4e6542c4 (patch)
tree96bd2e096a12cbd81994f9a772a513495b57d71f /Python
parentb4e232c4b5d977578b3c6aa86d8b76085167c313 (diff)
downloadcpython-7a341724e4dc8188f01ac338deaa414c4e6542c4.zip
cpython-7a341724e4dc8188f01ac338deaa414c4e6542c4.tar.gz
cpython-7a341724e4dc8188f01ac338deaa414c4e6542c4.tar.bz2
[3.11] GH-93252: Fix error handling for failed Python calls (GH-94693) (GH-94708)
Automerge-Triggered-By: GH:tiran
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 1a54545..c69ea21 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -6370,7 +6370,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;
@@ -6392,6 +6392,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_nlocalsplus +
+ frame->f_code->co_stacksize + FRAME_SPECIALS_SIZE == tstate->datastack_top);
tstate->recursion_remaining--;
assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame);
assert(frame->owner == FRAME_OWNED_BY_THREAD);