summaryrefslogtreecommitdiffstats
path: root/Python/frame.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-03-22 12:57:19 (GMT)
committerGitHub <noreply@github.com>2022-03-22 12:57:19 (GMT)
commit49daf6dba8178c5ae5d4d65408b20566d39c36a8 (patch)
tree4cb58165463cc7fd136337716f3af631c563a908 /Python/frame.c
parent88872a29f19092d2fde27365af230abd6d301941 (diff)
downloadcpython-49daf6dba8178c5ae5d4d65408b20566d39c36a8.zip
cpython-49daf6dba8178c5ae5d4d65408b20566d39c36a8.tar.gz
cpython-49daf6dba8178c5ae5d4d65408b20566d39c36a8.tar.bz2
bpo-47045: Remove `f_state` field (GH-31963)
* Remove the f_state field from _PyInterpreterFrame * Make ownership of the frame explicit, replacing the is_generator field with an owner field.
Diffstat (limited to 'Python/frame.c')
-rw-r--r--Python/frame.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Python/frame.c b/Python/frame.c
index 20b4f81..3396ed8 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -37,7 +37,8 @@ _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
Py_XDECREF(error_traceback);
}
else {
- f->f_owns_frame = 0;
+ assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
+ assert(frame->owner != FRAME_CLEARED);
f->f_frame = frame;
frame->frame_obj = f;
PyErr_Restore(error_type, error_value, error_traceback);
@@ -57,12 +58,13 @@ _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
static void
take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
{
- assert(f->f_owns_frame == 0);
+ assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
+ assert(frame->owner != FRAME_CLEARED);
Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame;
memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
frame = (_PyInterpreterFrame *)f->_f_frame_data;
- f->f_owns_frame = 1;
f->f_frame = frame;
+ frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
assert(f->f_back == NULL);
if (frame->previous != NULL) {
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
@@ -88,7 +90,8 @@ _PyFrame_Clear(_PyInterpreterFrame *frame)
{
/* It is the responsibility of the owning generator/coroutine
* to have cleared the enclosing generator, if any. */
- assert(!frame->is_generator);
+ assert(frame->owner != FRAME_OWNED_BY_GENERATOR ||
+ _PyFrame_GetGenerator(frame)->gi_frame_state == FRAME_CLEARED);
if (frame->frame_obj) {
PyFrameObject *f = frame->frame_obj;
frame->frame_obj = NULL;