Repository navigation
Conversation
picnixz
reviewed
Nov 28, 2026
| frame_exc = sys.exception() | ||
| def _fix_exception_context(new_exc, old_exc): | ||
| if new_exc is old_exc: | ||
| # Re-raising the pending exception preserves its context. |
Member
There was a problem hiding this comment.
This comment doesn't seem to be relevant.
|
Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate. Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors. This contribution appears to have been authored with AI assistance. Please explain your contribution in your own words and describe how you checked its correctness. Please read our guidelines for using AI tools. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #162738
Preserve the existing
__context__when an exit callback re-raises the pending exception. This preventsExitStackandAsyncExitStackfrom setting the exception as its own contexтThe regression test checks that both stacks preserve the original exception from the
withbody as the context of the cleanup exceptionexception.__context__#162738