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 Skylion007
Recipients Henry Schreiner, Mark.Shannon, Skylion007, eric.snow, gregory.p.smith, pablogsal, terry.reedy, vstinner
Date 2022-02-07.16:02:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The frame object I am referring to was:

PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());

This frame can not be used with PyObject_GetAttrString. Is there anyway to get the PyObject* associated with a PyFrameObject*? It seems weird that some functionality is just not accessible using the Stable ABI of PyThreadState_GetFrame . 

To elabroate: I was referring to the migration guide in the changelog btw:

    f_code: removed, use PyFrame_GetCode() instead. Warning: the function returns a strong reference, need to call Py_DECREF().

    f_back: changed (see below), use PyFrame_GetBack().

    f_builtins: removed, use PyObject_GetAttrString(frame, "f_builtins").
    // this frame object actually has to be a PyObject*, the old one was a  PyFrameObject* . Dropping this in does not work. 
    f_globals: removed, use PyObject_GetAttrString(frame, "f_globals").

    f_locals: removed, use PyObject_GetAttrString(frame, "f_locals").

    f_lasti: removed, use PyObject_GetAttrString(frame, "f_lasti").

I tried importing sys._getframe(), but that gave an attribute error interestingly enough. Run a full code snippit here works:, but is really slow and we would like avoid having to rely on it. Not to mention relying on a function that is an starts with an underscore seems like it really should be avoided.
Date User Action Args
2022-02-07 16:02:06Skylion007setrecipients: + Skylion007, terry.reedy, gregory.p.smith, vstinner, Mark.Shannon, eric.snow, Henry Schreiner, pablogsal
2022-02-07 16:02:06Skylion007setmessageid: <>
2022-02-07 16:02:06Skylion007linkissue46166 messages
2022-02-07 16:02:06Skylion007create