GeezerVison is showing github.com — Fix asyncio compile by youknowone · Pull Request #6739 · RustPython/RustPython
Conversation
youknowone
commented
Jan 15, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fix #6736
Close #6737
cc @terryluan12
Summary by CodeRabbit
- Bug Fixes
- Adjusted exception re-raising behavior in finally blocks for proper routing through exception handlers in the generated code.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
The patch modifies exception re-raising behavior within try-finally unwinding paths in the compiler's bytecode generation. It ensures that before emitting a RERAISE instruction, the FinallyEnd fblock is properly popped, the previous exception is explicitly copied from the stack, and the exception context is restored before re-raising to route exceptions to outer handlers correctly.
Changes
| Cohort / File(s) |
Summary |
Exception Re-raising in Try-Finally Unwinding crates/codegen/src/compile.rs |
Modified RERAISE logic to pop FinallyEnd fblock prior to re-raising; added explicit stack manipulation (COPY index 2) to restore previous exception state; inserted POP_EXCEPT to restore exception context, ensuring exceptions route to outer exception handlers rather than intermediate cleanup blocks. Changes applied symmetrically across both normal and exception-path handling branches. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
#6545: Modifies exception re-raise and unwind handling in compile.rs with adjustments to reraise paths, fblocks, and stack state management around finally blocks.
Poem
🐰 In finally blocks where exceptions dwell,
We pop the cleanup, then reraise bell,
Stack state aligned, the handlers now see,
Exceptions escape where they ought to be!
No more loops spinning, just control flow clean, ✨
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Title check |
❓ Inconclusive |
The title is vague and generic, using non-descriptive language that doesn't clarify what specific asyncio compilation issue is being fixed. |
Revise the title to be more specific, such as 'Fix exception routing in try-finally with async/await' or 'Fix CancelledError re-raising in asyncio Condition.wait', to better convey the nature of the fix. |
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Linked Issues check |
✅ Passed |
The code changes directly address the core issue: fixing exception routing so that re-raised exceptions in finally blocks proceed to outer handlers rather than re-entering cleanup loops, matching CPython behavior. |
| Out of Scope Changes check |
✅ Passed |
All changes in compile.rs are focused on fixing the exception routing logic in try-finally-await control flow, directly addressing the linked issues without introducing unrelated modifications. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📜 Recent review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 609dbb1 and 5ecb9c3.
📒 Files selected for processing (1)
crates/codegen/src/compile.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style using cargo fmt to format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/codegen/src/compile.rs
🔇 Additional comments (2)
crates/codegen/src/compile.rs (2)
2550-2566: Good: pop FinallyEnd before RERAISE to avoid cleanup re-entry.
This ordering plus the Copy/PopExcept restore keeps the rethrow routed to the outer handler as intended.
2850-2865: Consistent exception-path rethrow handling in finally.
Popping FinallyEnd before restoring prev_exc keeps the rethrow targeted at the outer handler, not cleanup.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
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 and usage tips.
|
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.
This was referenced Jan 16, 2026
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.
Investigate asyncio compiler error
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.
|