GeezerVison is showing github.com — Fix `staticmethod` and `classmethod` repr error propagation by YangSiJun528 · Pull Request #8371 · RustPython/RustPython
Conversation
YangSiJun528
commented
Jul 25, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- Propagate exceptions from the
repr() implementations of staticmethod and classmethod.
- Add regression tests for both descriptor types.
staticmethod and classmethod used repr(vm).unwrap() in their repr_str() implementations, which turned exceptions raised by the wrapped object's __repr__() into Rust panics.
Since repr_str() already returns PyResult<String>, this change uses ? to propagate the original Python exception unchanged, matching CPython's behavior.
Testing
cargo run -- extra_tests/snippets/syntax_class.py
Regression tests were added for both descriptor types.
Before this change, both test cases triggered a Rust panic when the wrapped object's __repr__() raised an exception.
AI assistance
Codex (GPT-5.6 Sol) was used to investigate and implement this change.
I reviewed and validated all AI-assisted work.
Summary by CodeRabbit
-
Bug Fixes
- Improved error handling when displaying
staticmethod and classmethod objects.
- Representation errors now propagate correctly instead of causing an unexpected application failure.
-
Tests
- Added coverage confirming that errors raised while representing wrapped callbacks are reported correctly.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Assisted-by: Codex:gpt-5.6-sol
coderabbitai
Bot
commented
Jul 25, 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: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2189c7b4-ad06-4315-916d-de99d4dc20b6
📥 Commits
Reviewing files that changed from the base of the PR and between 003ebec and b9b219d.
📒 Files selected for processing (3)
crates/vm/src/builtins/classmethod.rs
crates/vm/src/builtins/staticmethod.rs
extra_tests/snippets/syntax_class.py
📝 Walkthrough
Walkthrough
Changes
Representation error propagation
| Layer / File(s) |
Summary |
Descriptor repr error handling crates/vm/src/builtins/classmethod.rs, crates/vm/src/builtins/staticmethod.rs, extra_tests/snippets/syntax_class.py |
classmethod and staticmethod now propagate callable repr failures instead of unwrapping and panicking; tests verify both raise the stored RuntimeError. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested reviewers: 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 clearly matches the main change: fixing repr error propagation for staticmethod and classmethod. |
| 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.
Thank you for working on it 👍 looks good!
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.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
z-ca-2026
Tag to track Contribution Academy 2026
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.