summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-11-07 08:49:30 (GMT)
committerGitHub <noreply@github.com>2023-11-07 08:49:30 (GMT)
commit13405ecffda6c66d6a5cf2a22dff892c108c69db (patch)
tree2e577ae47a09aa34276d2ce4d1d10f373116eb0a /Objects
parentd2ddfccfb40e22bbdd75b28b444fd7b33dfe38db (diff)
downloadcpython-13405ecffda6c66d6a5cf2a22dff892c108c69db.zip
cpython-13405ecffda6c66d6a5cf2a22dff892c108c69db.tar.gz
cpython-13405ecffda6c66d6a5cf2a22dff892c108c69db.tar.bz2
gh-79932: raise exception if frame.clear() is called on a suspended frame (#111792)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 3a10f62..be330a7 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -937,6 +937,9 @@ frame_clear(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
if (gen->gi_frame_state == FRAME_EXECUTING) {
goto running;
}
+ if (FRAME_STATE_SUSPENDED(gen->gi_frame_state)) {
+ goto suspended;
+ }
_PyGen_Finalize((PyObject *)gen);
}
else if (f->f_frame->owner == FRAME_OWNED_BY_THREAD) {
@@ -951,6 +954,10 @@ running:
PyErr_SetString(PyExc_RuntimeError,
"cannot clear an executing frame");
return NULL;
+suspended:
+ PyErr_SetString(PyExc_RuntimeError,
+ "cannot clear a suspended frame");
+ return NULL;
}
PyDoc_STRVAR(clear__doc__,