diff --git a/pep-0654.rst b/pep-0654.rst index 7932fbafb..3faa58c35 100644 --- a/pep-0654.rst +++ b/pep-0654.rst @@ -186,30 +186,31 @@ contains only those exceptions for which the condition is true: ... ) ... ] ... ) + >>> import traceback >>> traceback.print_exception(eg) - | ExceptionGroup: one + | ExceptionGroup: one (3 sub-exceptions) +-+---------------- 1 ---------------- | TypeError: 1 +---------------- 2 ---------------- - | ExceptionGroup: two + | ExceptionGroup: two (2 sub-exceptions) +-+---------------- 1 ---------------- | TypeError: 2 +---------------- 2 ---------------- | ValueError: 3 +------------------------------------ +---------------- 3 ---------------- - | ExceptionGroup: three + | ExceptionGroup: three (1 sub-exception) +-+---------------- 1 ---------------- | OSError: 4 +------------------------------------ >>> type_errors = eg.subgroup(lambda e: isinstance(e, TypeError)) >>> traceback.print_exception(type_errors) - | ExceptionGroup: one + | ExceptionGroup: one (2 sub-exceptions) +-+---------------- 1 ---------------- | TypeError: 1 +---------------- 2 ---------------- - | ExceptionGroup: two + | ExceptionGroup: two (1 sub-exception) +-+---------------- 1 ---------------- | TypeError: 2 +------------------------------------ @@ -240,23 +241,23 @@ If both the subgroup and its complement are needed, the >>> type_errors, other_errors = eg.split(lambda e: isinstance(e, TypeError)) >>> traceback.print_exception(type_errors) - | ExceptionGroup: one + | ExceptionGroup: one (2 sub-exceptions) +-+---------------- 1 ---------------- | TypeError: 1 +---------------- 2 ---------------- - | ExceptionGroup: two + | ExceptionGroup: two (1 sub-exception) +-+---------------- 1 ---------------- | TypeError: 2 +------------------------------------ >>> traceback.print_exception(other_errors) - | ExceptionGroup: one + | ExceptionGroup: one (2 sub-exceptions) +-+---------------- 1 ---------------- - | ExceptionGroup: two + | ExceptionGroup: two (1 sub-exception) +-+---------------- 1 ---------------- | ValueError: 3 +------------------------------------ +---------------- 2 ---------------- - | ExceptionGroup: three + | ExceptionGroup: three (1 sub-exception) +-+---------------- 1 ---------------- | OSError: 4 +------------------------------------ @@ -387,7 +388,7 @@ in the following example: >>> raise ExceptionGroup("two", [f(2), eg]) + Exception Group Traceback (most recent call last): | File "", line 1, in - | ExceptionGroup: two + | ExceptionGroup: two (2 sub-exceptions) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "", line 3, in f @@ -395,7 +396,7 @@ in the following example: +---------------- 2 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: one + | ExceptionGroup: one (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "", line 3, in f @@ -802,29 +803,29 @@ merged with the unhandled ``TypeErrors``. ... *ValueError: ExceptionGroup('eg', [ValueError(1), ExceptionGroup('nested', [ValueError(6)])]) *OSError: ExceptionGroup('eg', [OSError(3), ExceptionGroup('nested', [OSError(4)])]) - | ExceptionGroup + | ExceptionGroup: (2 sub-exceptions) +-+---------------- 1 ---------------- | Exception Group Traceback (most recent call last): | File "", line 15, in | File "", line 2, in - | ExceptionGroup: eg + | ExceptionGroup: eg (2 sub-exceptions) +-+---------------- 1 ---------------- | ValueError: 1 +---------------- 2 ---------------- - | ExceptionGroup: nested + | ExceptionGroup: nested (1 sub-exception) +-+---------------- 1 ---------------- | ValueError: 6 +------------------------------------ +---------------- 2 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: eg + | ExceptionGroup: eg (3 sub-exceptions) +-+---------------- 1 ---------------- | TypeError: 2 +---------------- 2 ---------------- | OSError: 3 +---------------- 3 ---------------- - | ExceptionGroup: nested + | ExceptionGroup: nested (2 sub-exceptions) +-+---------------- 1 ---------------- | OSError: 4 +---------------- 2 ---------------- @@ -848,11 +849,11 @@ it into the new ``ExceptionGroup``. ... except* ValueError: ... raise ExceptionGroup("two", [KeyError('x'), KeyError('y')]) ... - | ExceptionGroup + | ExceptionGroup: (2 sub-exceptions) +-+---------------- 1 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: one + | ExceptionGroup: one (1 sub-exception) +-+---------------- 1 ---------------- | ValueError: a +------------------------------------ @@ -861,7 +862,7 @@ it into the new ``ExceptionGroup``. | | Exception Group Traceback (most recent call last): | File "", line 4, in - | ExceptionGroup: two + | ExceptionGroup: two (2 sub-exceptions) +-+---------------- 1 ---------------- | KeyError: 'x' +---------------- 2 ---------------- @@ -870,7 +871,7 @@ it into the new ``ExceptionGroup``. +---------------- 2 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: one + | ExceptionGroup: one (1 sub-exception) +-+---------------- 1 ---------------- | TypeError: b +------------------------------------ @@ -891,7 +892,7 @@ chaining: ... except* TypeError as e: ... raise ValueError('bad value') from e ... - | ExceptionGroup + | ExceptionGroup: (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "", line 2, in @@ -937,11 +938,11 @@ direct child of the new exception group created for that: ... except* ValueError: ... raise KeyError('x') ... - | ExceptionGroup + | ExceptionGroup: (1 sub-exception) +-+---------------- 1 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: eg + | ExceptionGroup: eg (1 sub-exception) +-+---------------- 1 ---------------- | ValueError: a +------------------------------------ @@ -958,11 +959,11 @@ direct child of the new exception group created for that: ... except* ValueError: ... raise KeyError('x') ... - | ExceptionGroup + | ExceptionGroup: (2 sub-exceptions) +-+---------------- 1 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: eg + | ExceptionGroup: eg (1 sub-exception) +-+---------------- 1 ---------------- | ValueError: a +------------------------------------ @@ -975,7 +976,7 @@ direct child of the new exception group created for that: +---------------- 2 ---------------- | Exception Group Traceback (most recent call last): | File "", line 2, in - | ExceptionGroup: eg + | ExceptionGroup: eg (1 sub-exception) +-+---------------- 1 ---------------- | TypeError: b +------------------------------------