gh-156133: Add PyUnstable_InterpreterFrame_GetLocals - #156134
Open
guilhermeleobas wants to merge 1 commit into
Open
gh-156133: Add PyUnstable_InterpreterFrame_GetLocals#156134guilhermeleobas wants to merge 1 commit into
PyUnstable_InterpreterFrame_GetLocals#156134guilhermeleobas wants to merge 1 commit into
Conversation
guilhermeleobas
requested review from
AA-Turner,
ZeroIntensity and
markshannon
as code owners
August 20, 2026 18:58
guilhermeleobas
force-pushed
the
guilhermeleobas/frame-getlocals
branch
2 times, most recently
from
August 20, 2026 19:03
2680016 to
049e1b3
Compare
Add an unstable C API that returns a strong reference to a single local variable of an internal interpreter frame, addressed by its localsplus index, with cell and free variables unboxed to their contents. Free variables are resolved from the function closure, so the API also works on a frame that has not started executing (before COPY_FREE_VARS runs) -- the case that motivated it -- and it does not modify the frame. Includes the PEP 689 deliverables: reference documentation in Doc/c-api/frame.rst, a What's New entry for 3.16, a Misc/NEWS.d blurb, and tests in Lib/test/test_capi/test_misc.py (TestInternalFrameApi) covering plain locals, a cell variable, and a free variable. Authored with the assistance of an AI coding agent (Claude Opus)
guilhermeleobas
force-pushed
the
guilhermeleobas/frame-getlocals
branch
from
August 20, 2026 19:16
049e1b3 to
9145c2f
Compare
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an unstable C API that reads a frame's local variables into a caller-provided array indexed by localsplus index, with cell and free variables unboxed to their contents. Free variables are resolved from the function closure, so the API also works on a frame that has not started executing (before COPY_FREE_VARS runs), which is the case that motivated it.
Includes the three PEP 689 deliverables:
Modules/_testinternalcapi.cdriven byLib/test/test_capi/test_frame_getlocals.pycovering plain locals, a cell variable, and a free variable).Authored with the assistance of an AI coding agent (Claude Opus)
PyUnstable_InterpreterFrame_GetLocalto read a local var from an interp. frame #156133