Skip to content

Using PyEval_GetFrame() to get the current frame in PEP 523 frame evaluator returns the previous frame #103609

Open
@markshannon

Description

@markshannon

See https://discuss.python.org/t/no-obvious-way-of-getting-pyframeobject-inside-a-frame-evaluation-function-in-python-3-11/25966

The problem is that PEP 523 frame evaluators are called before the frame is complete, and PyEval_EvalFrame() skips incomplete frames.
Perhaps PyEval_EvalFrame() should only be called after the frame is complete.

This is a subtle change to semantics from 3.11, but is closer to 3.10 and previous behavior.

We could implement this efficiently, using the instrumentation mechanism of PEP 669, dedicating tool ID 5 to PEP 523.

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions