Skip to content

Exception groups raised from another exception print their cause chain twice #14828

Description

@SemTiOne

Found while working with #14781.

When an ExceptionGroup is raised from another exception, the cause is printed twice in the traceback output. This is the same root cause as #8321, but the BaseExceptionGroup branch in repr_excinfo() was missed.

Minimal example:

def test_repro():
    try:
        raise RuntimeError("original cause")
    except RuntimeError as exc:
        raise ExceptionGroup("group", [ValueError("inner")]) from exc

RuntimeError: original cause and the "The above exception was the direct cause" line appear twice: once from traceback.format_exception() (see #9159) walking __cause__ itself, and once more from pytest's chain-walking loop.

Environment

  • 9.2.0.dev117+g2886fc64b.d20260729
  • Python 3.14.3
  • Windows

Packages

  • attrs: 25.4.0
  • exceptiongroup: 1.3.1
  • iniconfig: 2.3.0
  • packaging: 26.0
  • pluggy: 1.6.0
  • pytest: 9.2.0.dev117+g2886fc64b.d20260729

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions