PEP-654: errors --> exceptions (#1871)
This commit is contained in:
parent
a49056a590
commit
31d814345e
|
@ -143,7 +143,7 @@ and ``try: ... except BaseExceptionGroup: ...``.
|
|||
|
||||
Both have a constructor that takes two positional-only arguments: a message
|
||||
string and a sequence of the nested exceptions, which are exposed in the
|
||||
fields ``message`` and ``errors``. For example:
|
||||
fields ``message`` and ``exceptions``. For example:
|
||||
``ExceptionGroup('issues', [ValueError('bad value'), TypeError('bad type')])``.
|
||||
The difference between them is that ``ExceptionGroup`` can only wrap
|
||||
``Exception`` subclasses while ``BaseExceptionGroup`` can wrap any
|
||||
|
@ -383,7 +383,7 @@ recursively, as follows:
|
|||
|
||||
tbs.append(exc.__traceback__)
|
||||
if isinstance(exc, ExceptionGroup):
|
||||
for e in exc.errors:
|
||||
for e in exc.exceptions:
|
||||
yield from leaf_generator(e, tbs)
|
||||
else:
|
||||
# exc is a leaf exception and its traceback
|
||||
|
@ -491,7 +491,7 @@ Exceptions are matched using a subclass check. For example:
|
|||
try:
|
||||
low_level_os_operation()
|
||||
except *OSError as eg:
|
||||
for e in eg.errors:
|
||||
for e in eg.exceptions:
|
||||
print(type(e).__name__)
|
||||
|
||||
could output:
|
||||
|
|
Loading…
Reference in New Issue