Skip to content

Display ExceptionGroup full message #287

@jbvsmo

Description

@jbvsmo

Python3.11 added the concept of exception groups and this is how the traceback is displayed on normal Python console:

>>> eg = ExceptionGroup('foo', [TypeError(10), ValueError(20)])
>>> raise eg
  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  | ExceptionGroup: foo (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | TypeError: 10
    +---------------- 2 ----------------
    | ValueError: 20
    +------------------------------------

But on lates jupyter console 6.6.3 (also qtconsole) it shows as:

In [1]: eg = ExceptionGroup('foo', [TypeError(10), ValueError(20)])
In [2]: raise eg
---------------------------------------------------------------------------
ExceptionGroup                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 raise eg

ExceptionGroup: foo (2 sub-exceptions)

According to PEP 654 you have to recursively go through the ExceptionGroup.exceptions and display them all which can include more exception groups.

Side note. If you type ExceptionG<tab>, or Ex<tab><tab> it will not autocomplete the name ExceptionGroup. It will though autocomplete Exception at the 1st <tab>... Something to check why

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