PEP 654: Clarifications after python-dev review (#1838)
- subgroup returns None for empty. - except *(TypeError, ExceptionGroup) is forbidden.
This commit is contained in:
parent
05fe23f12b
commit
13be7c414f
|
@ -186,7 +186,9 @@ contains only those exceptions for which the condition is true:
|
|||
|
||||
|
||||
Empty nested ``ExceptionGroups`` are omitted from the result, as in the
|
||||
case of ``ExceptionGroup("three")`` in the example above. The original ``eg``
|
||||
case of ``ExceptionGroup("three")`` in the example above. If none of the
|
||||
leaf exceptions match the condition, ``subgroup`` returns ``None`` rather
|
||||
than an empty ``ExceptionGroup``. The original ``eg``
|
||||
is unchanged by ``subgroup``, but the value returned is not necessarily a full
|
||||
new copy. Leaf exceptions are not copied, nor are ``ExceptionGroups`` which are
|
||||
fully contained in the result. When it is necessary to partition an
|
||||
|
@ -860,6 +862,11 @@ with ``except*`` because the latter is ambiguous:
|
|||
except *ExceptionGroup: # <- Runtime error
|
||||
pass
|
||||
|
||||
try:
|
||||
...
|
||||
except *(TypeError, ExceptionGroup): # <- Runtime error
|
||||
pass
|
||||
|
||||
|
||||
An empty "match anything" ``except*`` block is not supported as its meaning may
|
||||
be confusing:
|
||||
|
|
Loading…
Reference in New Issue