GeezerVison is showing github.com — Add more dict functions to c-api by bschoenmaeckers · Pull Request #8269 · RustPython/RustPython
Conversation
bschoenmaeckers
commented
Jul 13, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
-
New Features
- Expanded dictionary support in the C API with
clear, set, get, and delete operations.
- Added UTF-8
char* key variants for string-key interop, including a reference-style lookup with a hit/miss success flag.
- Introduced error-aware vs raw lookups, with clearer behavior for misses and propagated errors.
-
Bug Fixes
- Improved handling of invalid UTF-8 keys by raising appropriate Python decoding exceptions.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jul 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d58b2bcd-8754-4a23-b587-9523fb35baa3
📥 Commits
Reviewing files that changed from the base of the PR and between 60e37fd and 3db5877.
📒 Files selected for processing (1)
crates/capi/src/dictobject.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/capi/src/dictobject.rs
📝 Walkthrough
Walkthrough
The dictionary C-API gains clear, string-key set/delete, object-key lookup, and string-key lookup functions. String keys are decoded from C strings, with invalid UTF-8 handled according to each API’s return contract.
Changes
Dictionary C-API
| Layer / File(s) |
Summary |
Dictionary clearing and string-key mutation crates/capi/src/dictobject.rs |
Adds PyDict_Clear, PyDict_SetItemString, and PyDict_DelItemString, including UTF-8 decoding for string keys. |
Object-key lookup crates/capi/src/dictobject.rs |
Adds PyDict_GetItem and PyDict_GetItemWithError with distinct missing-entry and error behavior. |
String-key lookup crates/capi/src/dictobject.rs |
Adds PyDict_GetItemString and PyDict_GetItemStringRef, including raw-pointer results, out-parameter initialization, and invalid UTF-8 handling. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Possibly related PRs
Suggested reviewers: 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 additional dict functions to the C API. |
| 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
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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/dictobject.rs`:
- Around line 90-110: Update PyDict_GetItemString so CStr::to_str() failures
propagate an appropriate decode exception through the existing with_vm result
instead of returning Ok(null_mut()). Preserve Ok(None) as the lookup-miss path,
but stop swallowing errors from dict.inner_getitem_opt; only lookup misses
should return a null pointer without an exception.
🪄 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: 8701ac58-1d3c-4a57-b681-83a4a95747cd
📥 Commits
Reviewing files that changed from the base of the PR and between a9c2c52 and 03ed6cf.
📒 Files selected for processing (1)
crates/capi/src/dictobject.rs
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
youknowone
pushed a commit
that referenced
this pull request
Sep 16, 2026
* Add more dict functions to c-api
* Review
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|