Fix __notes__ from outermost exception shown on all exceptions in chain#3964
Closed
veeceey wants to merge 1 commit intoTextualize:masterfrom
Closed
Fix __notes__ from outermost exception shown on all exceptions in chain#3964veeceey wants to merge 1 commit intoTextualize:masterfrom
veeceey wants to merge 1 commit intoTextualize:masterfrom
Conversation
Move the `notes` assignment inside the `while True` loop in `Traceback.extract()` so that each exception in a chained traceback gets its own `__notes__` instead of reusing the outermost exception's notes for every `Stack` in the chain. Fixes Textualize#3960 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
__notes__from outermost exception shown on all exceptions in chain #3960 --Traceback.__notes__from the outermost exception was incorrectly displayed on every exception in a chained traceback.notesassignment (getattr(exc_value, "__notes__", ...)) from before thewhile Trueloop to inside it, so eachStackreads notes from its ownexc_valuerather than reusing the same list for all.Root Cause
In
Traceback.extract(), thenoteslist was read once from the initialexc_valuebefore the loop that walks__cause__/__context__. Since the samenotesreference was passed to everyStack, all exceptions in the chain incorrectly displayed the outermost exception's notes.Test plan
RuntimeError, notValueErrortest_notes_chained_exceptions-- notes on outer only, inner has nonetest_notes_on_each_chained_exception-- each exception has its own distinct notes🤖 Generated with Claude Code