FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-156133: Add `PyUnstable_InterpreterFrame_GetLocal` by guilhermeleobas · Pull Request #156134 · python/cpython · GitHub

/ cpython Public

gh-156133: Add PyUnstable_InterpreterFrame_GetLocal - #156134

Open
guilhermeleobas wants to merge 2 commits into
python:mainfrom
guilhermeleobas:guilhermeleobas/frame-getlocals
Open

gh-156133: Add PyUnstable_InterpreterFrame_GetLocal#156134
guilhermeleobas wants to merge 2 commits into
python:mainfrom
guilhermeleobas:guilhermeleobas/frame-getlocals

Conversation

guilhermeleobas commented Aug 20, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

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:

  1. reference documentation in Doc/c-api/frame.rst
  2. a What's New entry for 3.16
  3. and tests (a C wrapper in Modules/_testinternalcapi.c driven by Lib/test/test_capi/test_frame_getlocals.py covering plain locals, a cell variable, and a free variable).

Authored with the assistance of an AI coding agent (Claude Opus)

python-cla-bot Bot commented Aug 20, 2026
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

read-the-docs-community Bot commented Aug 20, 2026
edited
Loading

Copy link
Copy Markdown

Comment thread Objects/frameobject.c Outdated
Comment thread Modules/_testinternalcapi.c Outdated
aisk changed the title gh-156133: Add PyUnstable_InterpreterFrame_GetLocals gh-156133: Add PyUnstable_InterpreterFrame_GetLocal Aug 21, 2026
Comment thread Objects/frameobject.c Outdated
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 cbb346a to d29acd6 Compare August 24, 2026 13:52

Copy link
Copy Markdown
Contributor Author

Thanks @aisk. I've addressed your comments.

aisk commented Aug 24, 2026

Copy link
Copy Markdown
Member

Hi, thank you for the contribution, but please avoid using force push in the future, see: https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

guilhermeleobas commented Aug 24, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

Sorry, it won't happen again. I did because the e-mail used in the commit was wrong and the cla-bot was failing.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL