Skip to content

Fix duplicated exception chain output when an exception group has a cause - #14829

Draft
SemTiOne wants to merge 1 commit into
pytest-dev:mainfrom
SemTiOne:fix-14828-exception-group-cause-dup
Draft

Fix duplicated exception chain output when an exception group has a cause#14829
SemTiOne wants to merge 1 commit into
pytest-dev:mainfrom
SemTiOne:fix-14828-exception-group-cause-dup

Conversation

@SemTiOne

@SemTiOne SemTiOne commented Aug 2, 2026

Copy link
Copy Markdown

Raising an ExceptionGroup from another exception printed the cause chain twice: once natively by format_exception() walking __cause__, and once more by pytest's chain-walking loop. The loop now stops after the native representation, which already includes the chain.

  • 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.
  • Closes Exception groups raised from another exception print their cause chain twice #14828
  • 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. See changelog/README.rst for details.
  • Add yourself to AUTHORS in alphabetical order.

…ause

An exception group raised from another exception used to print that
exception's cause chain twice: once natively by format_exception (which
walks the chain), and once more by the exception chain loop in
repr_excinfo.

Stop walking the chain in the loop after the native representation has
already been generated, since it includes the cause/context chain.

Co-authored-by: Claude <noreply@anthropic.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Aug 2, 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.

Exception groups raised from another exception print their cause chain twice

1 participant