GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add more eval functions to c-api by bschoenmaeckers · Pull Request #8244 · RustPython/RustPython

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented Jul 8, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Extended the C evaluation/frame API with new helpers to evaluate frames and fetch the current frame’s globals, locals, and builtins.
    • Added callable introspection via a new function descriptor helper.
  • Bug Fixes
    • Improved FFI return handling for strings and raw pointers, including clearer “no current frame” behavior.
  • Compatibility / API Updates
    • Updated exported frame handle types to provide more reliable access to frame code objects and line numbers.
    • Removed the older builtins accessor in favor of current-frame accessors.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 948f8770-5ef2-497f-b694-51e17105cff0

📥 Commits

Reviewing files that changed from the base of the PR and between ddf148d and a01eae7.

📒 Files selected for processing (1)
  • crates/capi/src/ceval.rs

📝 Walkthrough

Walkthrough

This PR extends the C-ABI eval and frame surface with frame execution, current-frame accessors, callable descriptor lookup, typed frame/code handles, and new FFI result conversions.

Changes

C-API eval/frame extension

Layer / File(s) Summary
Import and FFI support
crates/capi/src/ceval.rs, crates/capi/src/util.rs
Updates ceval imports and adds FfiResult conversions for raw Py pointers and C strings.
Frame evaluation entry points
crates/capi/src/ceval.rs
Adds PyEval_EvalFrame and PyEval_EvalFrameEx, forwarding execution through vm.run_frame.
Frame accessors
crates/capi/src/ceval.rs
Replaces PyEval_GetBuiltins with current-frame accessors for frame, builtins, globals, locals, and globals/locals pointers derived from the active frame.
Callable descriptor helper
crates/capi/src/ceval.rs
Adds PyEval_GetFuncDesc, which inspects callable runtime classes and returns the matching descriptor suffix.
PyFrameObject FFI handle
crates/capi/src/pyframe.rs
Adds typed PyFrameObject and PyCodeObject handles and updates frame accessors to use them directly.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • RustPython/RustPython#7927: Overlaps on crates/capi/src/ceval.rs and the PyEval_GetBuiltins surface that this PR replaces with frame-oriented accessors.
  • RustPython/RustPython#8215: Related to the crates/capi/src/pyframe.rs FFI frame accessors that this PR retypes to PyFrameObject.

Suggested reviewers: youknowone, ShaharNaveh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: expanding the C API with additional eval-related functions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-more-eval branch from 00c0b14 to 51bc472 Compare July 8, 2026 18:50
coderabbitai[bot]
coderabbitai Bot reviewed Jul 8, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/capi/src/ceval.rs`:
- Around line 118-124: `PyEval_GetLocals` is returning the frame’s locals
mapping without first synchronizing fast locals, so update the
`PyEval_GetLocals` implementation in `ceval.rs` to use the same synchronization
path as `frame.locals(vm)` before converting to a raw `PyObject`. Keep the
existing `with_vm`/`current_frame` flow, but fetch the synced locals mapping
from the frame rather than calling `frame.locals.as_object(vm)` directly so the
behavior matches CPython.
- Around line 127-150: PyEval_GetFuncName is returning borrowed string pointers
that may not be stable or NUL-terminated, especially for __name__ and cls.name()
paths. Update PyEval_GetFuncName to construct and return a stable C string
(matching the approach used by PyEval_GetFuncDesc) by converting the chosen name
into a CString or equivalent CStr-backed value before returning, and keep the
recursive bound_method_type path consistent with that same ownership model.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 0e718ea3-ba8f-4190-9854-61beccd59be6

📥 Commits

Reviewing files that changed from the base of the PR and between 5c36d5c and 00c0b14.

📒 Files selected for processing (2)
  • crates/capi/src/ceval.rs
  • crates/capi/src/util.rs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/capi/src/ceval.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread crates/capi/src/ceval.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bschoenmaeckers
Add more eval functions to c-api
0dfff5f
@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-more-eval branch from 51bc472 to 0dfff5f Compare July 8, 2026 18:53
coderabbitai[bot]
coderabbitai Bot reviewed Jul 8, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/capi/src/pyframe.rs`:
- Around line 8-16: `PyFrame_GetLineNumber` currently converts the `f_lineno()`
result from `usize` to `c_int` with a blind cast, which can truncate large
values. Update the `PyFrame_GetLineNumber` implementation in `pyframe.rs` to use
a checked conversion or explicit bounds handling before returning
`core::ffi::c_int`, and keep `PyFrame_GetCode` unchanged since its ownership is
already correct.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 6ac3a184-adae-42c0-8fb0-bc3796bc0001

📥 Commits

Reviewing files that changed from the base of the PR and between 00c0b14 and 0dfff5f.

📒 Files selected for processing (3)
  • crates/capi/src/ceval.rs
  • crates/capi/src/pyframe.rs
  • crates/capi/src/util.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/capi/src/util.rs
  • crates/capi/src/ceval.rs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/capi/src/pyframe.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

bschoenmaeckers added 2 commits July 8, 2026 21:23
@bschoenmaeckers
Review
ddf148d
@bschoenmaeckers
Remove PyEval_GetFuncName
a01eae7
youknowone
youknowone approved these changes Jul 9, 2026
View reviewed changes
@youknowone
youknowone merged commit d3f0729 into RustPython:main Jul 9, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bschoenmaeckers
bschoenmaeckers deleted the c-api-more-eval branch July 9, 2026 06:34
@coderabbitai coderabbitai Bot mentioned this pull request Jul 31, 2026
Split InterpreterFrame from FrameObject for stack-allocated execution #8354
Merged
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@bschoenmaeckers
Add more eval functions to c-api (#8244)
b6ade8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bschoenmaeckers @youknowone
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.