@@ -343,7 +343,7 @@ the case of :keyword:`except`, but in the case of exception groups we can have
343
343
partial matches when the type matches some of the exceptions in the group.
344
344
This means that multiple :keyword: `!except* ` clauses can execute,
345
345
each handling part of the exception group.
346
- Each clause executes once and handles an exception group
346
+ Each clause executes at most once and handles an exception group
347
347
of all matching exceptions. Each exception in the group is handled by at most
348
348
one :keyword: `!except* ` clause, the first that matches it. ::
349
349
@@ -364,10 +364,22 @@ one :keyword:`!except*` clause, the first that matches it. ::
364
364
| ValueError: 1
365
365
+------------------------------------
366
366
367
+
367
368
Any remaining exceptions that were not handled by any :keyword: `!except* `
368
369
clause are re-raised at the end, combined into an exception group along with
369
370
all exceptions that were raised from within :keyword: `!except* ` clauses.
370
371
372
+ If the raised exception is not an exception group and its type matches
373
+ one of the :keyword: `!except* ` clauses, it is caught and wrapped by an
374
+ exception group with an empty message string. ::
375
+
376
+ >>> try:
377
+ ... raise BlockingIOError
378
+ ... except* BlockingIOError as e:
379
+ ... print(repr(e))
380
+ ...
381
+ ExceptionGroup('', (BlockingIOError()))
382
+
371
383
An :keyword: `!except* ` clause must have a matching type,
372
384
and this type cannot be a subclass of :exc: `BaseExceptionGroup `.
373
385
It is not possible to mix :keyword: `except ` and :keyword: `!except* `
0 commit comments