mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
gh-79932: raise exception if frame.clear() is called on a suspended frame (#111792)
This commit is contained in:
parent
d2ddfccfb4
commit
13405ecffd
5 changed files with 27 additions and 7 deletions
|
|
@ -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__,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue