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 abstract functions to c-api by bschoenmaeckers · Pull Request #8202 · RustPython/RustPython

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented Jun 30, 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
    • Expanded C API support for invoking Python callables, including no-argument calls and vectorcall-style dispatch with keyword arguments.
    • Added C API helpers to delete mapping items by UTF-8 string keys and to format objects (with optional format specifier).
    • Exposed object length and runtime type via new C API entry points.
  • Bug Fixes
    • Improved item deletion when provided UTF-8 keys are invalid by surfacing decoding errors instead of failing silently.

Sorry, something went wrong.

Uh oh!

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

All reactions
@coderabbitai

coderabbitai Bot commented Jun 30, 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: e1152a86-3def-407f-a7d4-a788608e2884

📥 Commits

Reviewing files that changed from the base of the PR and between 71d44f0 and 3301c67.

📒 Files selected for processing (1)
  • crates/capi/src/abstract_.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/capi/src/abstract_.rs

📝 Walkthrough

Walkthrough

Six new C-ABI exports are added in crates/capi/src/abstract_.rs for callable dispatch, UTF-8 key deletion, formatting, length, and type access. The file also adds C-string handling imports.

Changes

C-ABI abstract protocol exports

Layer / File(s) Summary
FFI imports and call wrappers
crates/capi/src/abstract_.rs
Adds CStr and c_char imports, and implements PyObject_CallObject plus PyVectorcall_Call for callable dispatch from the C-ABI.
DelItemString, Format, Length, and Type exports
crates/capi/src/abstract_.rs
Adds PyObject_DelItemString, PyObject_Format, PyObject_Length, and PyObject_Type exports.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • RustPython/RustPython#7937: Both PRs extend crates/capi/src/abstract_.rs with new C-ABI function wrappers for invoking Python callables.
  • RustPython/RustPython#8035: Both PRs modify crates/capi/src/abstract_.rs to shape the PyObject_Size C-ABI surface, including a direct PyObject_Length wrapper.
  • RustPython/RustPython#7882: Also extends crates/capi/src/abstract_.rs with new PyObject_* C-ABI protocol wrappers.

Suggested reviewers: ShaharNaveh, youknowone

🚥 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: adding more abstract C-API functions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

coderabbitai[bot]
coderabbitai Bot reviewed Jun 30, 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/abstract_.rs`:
- Around line 191-199: PyObject_Format currently dereferences format_spec
unconditionally, which crashes when callers pass NULL. Update the
PyObject_Format function to detect a null format_spec and treat it as an empty
PyStr before calling try_downcast_ref::<PyStr>(vm), while leaving the obj
handling and vm.format call unchanged.
- Around line 139-147: PyVectorcall_Call is currently routed through
PyObject_Call, which bypasses the vectorcall fast path and can recurse when used
as the callable’s call bridge. Update PyVectorcall_Call in abstract_.rs to
dispatch via the vectorcall entrypoint instead of the normal call slot, using
the existing vectorcall-related helpers/types in this module so the tp_call
bridge preserves vectorcall behavior.
🪄 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: fc3c192e-d650-46b7-b380-4fa319477111

📥 Commits

Reviewing files that changed from the base of the PR and between 33c0cf7 and 662e26b.

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

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

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

Uh oh!

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

coderabbitai[bot]
coderabbitai Bot reviewed Jun 30, 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/abstract_.rs`:
- Around line 225-228: In PyObject_Format within abstract_.rs, the current
try_downcast_ref::<PyStr> path returns a generic downcast error for non-string
format_spec values, but this C API should map that case to SystemError to match
CPython. Update the handling around format_spec.as_ref() so non-str specs are
explicitly translated into a SystemError before continuing, while keeping the
existing empty_str fallback for None.
🪄 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: 273e1473-5959-4bf5-9667-93d87a2fb932

📥 Commits

Reviewing files that changed from the base of the PR and between 662e26b and 4c4cc0d.

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

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-more-abstract branch from 4c4cc0d to 71d44f0 Compare July 3, 2026 07:19
youknowone
youknowone approved these changes Jul 4, 2026
View reviewed changes
bschoenmaeckers added 2 commits July 5, 2026 19:38
@bschoenmaeckers
Add more abstract functions to c-api
6037e43
@bschoenmaeckers
Review
3301c67
@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-more-abstract branch from 71d44f0 to 3301c67 Compare July 5, 2026 17:38
@youknowone
youknowone merged commit 3f9d80b into RustPython:main Jul 6, 2026
26 checks passed

Uh oh!

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

@bschoenmaeckers
bschoenmaeckers deleted the c-api-more-abstract branch July 6, 2026 11:51
@coderabbitai coderabbitai Bot mentioned this pull request Jul 13, 2026
Add more dict functions to c-api #8269
Merged
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@bschoenmaeckers
Add more abstract functions to c-api (#8202)
80e384e
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 01402503 — 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.