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 — Fix asyncio compile by youknowone · Pull Request #6739 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Jan 15, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

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.

All reactions
@coderabbitai

coderabbitai Bot commented Jan 15, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
📝 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
  • 📝 Generate docstrings


📜 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@youknowone
Fix asyncio compile
5ecb9c3
@youknowone
youknowone force-pushed the asyncio branch from c2939b4 to 5ecb9c3 Compare January 15, 2026 16:59
@youknowone
youknowone marked this pull request as ready for review January 15, 2026 23:47
@youknowone
youknowone merged commit a0ace05 into RustPython:main Jan 16, 2026
23 of 24 checks passed

Uh oh!

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

@youknowone
youknowone deleted the asyncio branch January 16, 2026 00:12
This was referenced Jan 16, 2026
RustPython version to 3.14 #6718
Merged
Fix asyncio related compiler/library issues #6837
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Feb 2, 2026
Fix test_asyncio for windows #6959
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

Investigate asyncio compiler error

Uh oh!

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

1 participant

@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.