[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-30 Thread Nick Coghlan
Nick Coghlan added the comment: Mark's suggested frame stack API makes sense to me, but being able to get/set specific values through the full frame API seems like it would be useful even if the lower level API existed - if we don't get one of the proxy PEPs in shape to land in 3.11, trace

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-42197: Disable automatic update of frame locals during tracing. -- ___ Python tracker ___

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: If PyFrameStack_GetVar(depth, name) is added, would it make PyFrame_GetVar() irrelevant? -- ___ Python tracker ___

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: See also: * bpo-46836: [C API] Move PyFrameObject to the internal C API. * bpo-46836: GH-32051 "Add Doc/c-api/frame.rst" * bpo-40421: [C API] Add getter functions for PyFrameObject and maybe move PyFrameObject to the internal C API. --

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread Mark Shannon
Mark Shannon added the comment: I'm looking into adding two new APIs. One to round out the getters for FrameObject and one to introspect the internal frame stack. It would probably make more sense to add this capability to the frame stack API, as it would avoid creating the frame object as

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: Currently, Tools/gdb/libpython.py uses PyFramePtr.iter_locals() which iterates on PyFrameObject.f_frame.localsplus. There is a PyFramePtr.get_var_by_name() function which only checks for frame variables in PyFrameObject.f_frame.localsplus, or look up in

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: > In Python 3.10, it's possible to call PyFrame_FastToLocalsWithError() on a > frame to get all variables as a dictionary. In 2018, it was decided to *not* document this function: see bpo-19431. In C, It is possible to call PyObject_GetAttrString(frame,

[issue47092] [C API] Add PyFrame_GetVar(frame, name) function

2022-03-22 Thread STINNER Victor
New submission from STINNER Victor : In Python 3.10, it's possible to call PyFrame_FastToLocalsWithError() on a frame to get all variables as a dictionary. In Python, getting frame.f_locals calls PyFrame_FastToLocalsWithError(). It's used by the pdb module for example: