Repository navigation
capi: add PyFrame_GetLocals, GetGlobals, GetBuiltins - #8761
Conversation
Wire the C-API getters to frame.f_locals, f_globals, and f_builtins, and cover write-through vs snapshot locals in a capi test. Assisted-by: Grok:4.6
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: RustPython/RustPython/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change exposes frame locals, globals, and builtins through public VM accessors and adds corresponding C API functions. Tests cover locals write behavior, locals snapshots, and globals or builtins object identity. ChangesFrame accessors
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant CAPI as C API caller
participant FrameAPI as Frame C API
participant Frame as FrameObject
participant Objects as Frame objects
CAPI->>FrameAPI: Call a frame getter
FrameAPI->>Frame: Read locals, globals, or builtins
Frame-->>FrameAPI: Return the corresponding object
FrameAPI-->>CAPI: Return PyObject pointer
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
These are not part of the limited api. Do you need them for something? |
One of checkbox below must be checked.
Summary
Add
PyFrame_GetLocals,PyFrame_GetGlobals, andPyFrame_GetBuiltinsas new-reference C-API getters forframe.f_locals,f_globals, andf_builtins.PyFrame_GetLocalsreturns the write-through mapping (aFrameLocalsProxyon optimized frames).PyEval_GetFrameLocalsremains the independentlocals()snapshot.Tests
cd crates/capi && cargo test -- get_locals_globals_builtinscd crates/capi && cargo clippy --all-targets -- -D warningsSummary by CodeRabbit