Skip to content

Fix duplicated exception chain output for exceptions without a traceback#14781

Open
SemTiOne wants to merge 1 commit into
pytest-dev:mainfrom
SemTiOne:fix-8321-chained-exception-dup
Open

Fix duplicated exception chain output for exceptions without a traceback#14781
SemTiOne wants to merge 1 commit into
pytest-dev:mainfrom
SemTiOne:fix-8321-chained-exception-dup

Conversation

@SemTiOne

Copy link
Copy Markdown

When an exception in a chain has no __traceback__ of its own, repr_excinfo() falls back to traceback.format_exception(), which defaults to chain=True and walks the rest of the chain itself, duplicating what pytest's own chain-walking loop then prints again right after.

Fix: pass chain=False to that fallback call.

Closes #8321

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create a new changelog file in the changelog directory, with a name like <ISSUE NUMBER>.<TYPE>.rst.
  • Add yourself to AUTHORS in alphabetical order.

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exceptions without a traceback print multiple times if chained

1 participant