Skip to content

ultratb hides the contents of ExceptionGroup errors #13753

@Zac-HD

Description

@Zac-HD

This probably isn't too bad yet, but Python 3.11 finally will be out next month, and ExceptionGroup is already seeing growing usage across the ecosystem - for example in Pytest, Hypothesis, and Trio. Ideally we'd get this working soon, so that users who only rarely update are likely to have a compatible set of packages before they hit this interaction.

As a simple reproducing example:

try:
    ExceptionGroup
except NameError:
    from exceptiongroup import ExceptionGroup

# Realistically these errors would have their own nested tracebacks, but for simplicity...
raise ExceptionGroup("Multiple errors", [ValueError("msg"), TypeError("msg")])

In the standard Python REPL, this shows:

>>> raise ExceptionGroup("Multiple errors", [ValueError("msg"), TypeError("msg")])
  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  | exceptiongroup.ExceptionGroup: Multiple errors (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | ValueError: msg
    +---------------- 2 ----------------
    | TypeError: msg
    +------------------------------------

but in IPython, or a Jupyter notebook, we only see the container exception:

In [2]: try:
   ...:     ExceptionGroup
   ...: except NameError:
   ...:     from exceptiongroup import ExceptionGroup
   ...: 
   ...: raise ExceptionGroup("Multiple errors", [ValueError("msg"), TypeError("msg")])
---------------------------------------------------------------------------
ExceptionGroup                            Traceback (most recent call last)
Input In [3], in <cell line: 6>()
      3 except NameError:
      4     from exceptiongroup import ExceptionGroup
----> 6 raise ExceptionGroup("Multiple errors", [ValueError("msg"), TypeError("msg")])

ExceptionGroup: Multiple errors (2 sub-exceptions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions