This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Mark.Shannon, vstinner
Date 2022-01-12.15:33:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642001581.89.0.653777729997.issue46356@roundup.psfhosted.org>
In-reply-to
Content
C extensions written for Python 3.10 and older which access directly to the PyFrameObject.f_back member build successfully on Python 3.11, but they can fail because f_back must not be read directly. f_back can be NULL even if the frame has an outer frame.

PyFrameObject*
PyFrame_GetBack(PyFrameObject *frame)
{
    assert(frame != NULL);
    PyFrameObject *back = frame->f_back;
    if (back == NULL && frame->f_frame->previous != NULL) {
        back = _PyFrame_GetFrameObject(frame->f_frame->previous);
    }
    Py_XINCREF(back);
    return back;
}

I suggest to remove or "hide" this member from the structure. For example, rename "f_back" to "_f_back" to advice developers to not access it directly.

See also bpo-46355: Document PyFrameObject and PyThreadState changes.
History
Date User Action Args
2022-01-12 15:33:01vstinnersetrecipients: + vstinner, Mark.Shannon
2022-01-12 15:33:01vstinnersetmessageid: <1642001581.89.0.653777729997.issue46356@roundup.psfhosted.org>
2022-01-12 15:33:01vstinnerlinkissue46356 messages
2022-01-12 15:33:01vstinnercreate