On 25.02.2022 14:29, Victor Stinner wrote:
On Fri, Feb 25, 2022 at 1:48 PM Marc-Andre Lemburg mal@egenix.com wrote:
On 25.02.2022 13:15, Victor Stinner wrote:
Hi,
tl; dr the C API of PyFrameObject changed. If you have issues, please speak up!
I moved the PyFrameObject structure to the internal C API headers. You should now use the public C API to access its members:
f_back
: use :c:func:PyFrame_GetBack
.You only mention C APIs, but inspection tools are often written in Python. How can they access and walk the frames on the stack ?
Are these members still available as Python attributes of the frame objects ?
As far as I know, frame object members which were available on Python 3.10 are still available in Python 3.11 using the Python API. For example, reading "frame.f_back" in Python remains perfectly fine.
That's why the What's New in Python 3.11 document now recommends to simply use PyObject_GetAttrString(): use the Python API from C :-)
Good to know, thanks.
Esp. walking the frame stack is important in Python for e.g. logging local variables in tracebacks or accessing context from the call stack further up.
Do you happen to know whether the current work on optimizations will break this approach by e.g. not always creating frames on the stack ?
Thanks,
Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Experts (#1, Feb 25 2022)
Python Projects, Coaching and Support ... https://www.egenix.com/ Python Product Development ... https://consulting.egenix.com/
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/