]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Remove asserts that confuse `enum _framestate` with `enum _frameowner` (GH-124148)
authorAnders Kaseorg <andersk@mit.edu>
Thu, 2 Jan 2025 16:55:33 +0000 (08:55 -0800)
committerGitHub <noreply@github.com>
Thu, 2 Jan 2025 16:55:33 +0000 (16:55 +0000)
The `owner` field of `_PyInterpreterFrame` is supposed to be a member of
`enum _frameowner`, but `FRAME_CLEARED` is a member of `enum _framestate`.

At present, it happens that `FRAME_CLEARED` is not numerically equal to any
member of `enum _frameowner`, but that could change in the future. The code
that incorrectly assigned `owner = FRAME_CLEARED` was deleted in commit
a53cc3f49463e50cb3e2b839b3a82e6bf7f73fee (GH-116687). Remove the incorrect
checks for `owner != FRAME_CLEARED` as well.

Python/frame.c

index 9a865e57d97cc6f0c1ece5361ef87e43ab79b2a8..6eb32bcce0b799231dbba3d92ff828cd4049894c 100644 (file)
@@ -40,7 +40,6 @@ _PyFrame_MakeAndSetFrameObject(_PyInterpreterFrame *frame)
     // here.
     assert(frame->frame_obj == NULL);
     assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
-    assert(frame->owner != FRAME_CLEARED);
     f->f_frame = frame;
     frame->frame_obj = f;
     return f;
@@ -51,7 +50,6 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
 {
     assert(frame->owner != FRAME_OWNED_BY_CSTACK);
     assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
-    assert(frame->owner != FRAME_CLEARED);
     Py_ssize_t size = ((char*)frame->stackpointer) - (char *)frame;
     memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
     frame = (_PyInterpreterFrame *)f->_f_frame_data;