Skip to content

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 8, 2026

Summary

  • Fixes [BUG] Traceback __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.
  • Moved the notes assignment (getattr(exc_value, "__notes__", ...)) from before the while True loop to inside it, so each Stack reads notes from its own exc_value rather than reusing the same list for all.
  • Added two regression tests: one verifying notes only appear on the exception that has them, and another verifying each exception in a chain gets its own distinct notes.

Root Cause

In Traceback.extract(), the notes list was read once from the initial exc_value before the loop that walks __cause__/__context__. Since the same notes reference was passed to every Stack, all exceptions in the chain incorrectly displayed the outermost exception's notes.

Test plan

  • Verified with the exact reproduction script from the issue -- note now only appears on RuntimeError, not ValueError
  • Added test_notes_chained_exceptions -- notes on outer only, inner has none
  • Added test_notes_on_each_chained_exception -- each exception has its own distinct notes
  • All 24 existing traceback tests pass (1 skipped)

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Traceback __notes__ from outermost exception shown on all exceptions in chain

2 participants