Message412761
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: https://github.com/pybind/pybind11/blob/96b943be1d39958661047eadac506745ba92b2bc/include/pybind11/pybind11.h#L2429, 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:06 | Skylion007 | set | recipients:
+ Skylion007, terry.reedy, gregory.p.smith, vstinner, Mark.Shannon, eric.snow, Henry Schreiner, pablogsal |
2022-02-07 16:02:06 | Skylion007 | set | messageid: <1644249726.24.0.529222346945.issue46166@roundup.psfhosted.org> |
2022-02-07 16:02:06 | Skylion007 | link | issue46166 messages |
2022-02-07 16:02:06 | Skylion007 | create | |
|