mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
PEP 415: Implement suppression of __context__ display with an exception attribute
This replaces the original PEP 409 implementation. See #14133.
This commit is contained in:
parent
d91dc62379
commit
d5a1c44455
12 changed files with 80 additions and 79 deletions
|
@ -119,15 +119,16 @@ def _iter_chain(exc, custom_tb=None, seen=None):
|
|||
seen = set()
|
||||
seen.add(exc)
|
||||
its = []
|
||||
context = exc.__context__
|
||||
cause = exc.__cause__
|
||||
if cause is Ellipsis:
|
||||
context = exc.__context__
|
||||
if context is not None and context not in seen:
|
||||
its.append(_iter_chain(context, None, seen))
|
||||
its.append([(_context_message, None)])
|
||||
elif cause is not None and cause not in seen:
|
||||
if cause is not None and cause not in seen:
|
||||
its.append(_iter_chain(cause, False, seen))
|
||||
its.append([(_cause_message, None)])
|
||||
elif (context is not None and
|
||||
not exc.__suppress_context__ and
|
||||
context not in seen):
|
||||
its.append(_iter_chain(context, None, seen))
|
||||
its.append([(_context_message, None)])
|
||||
its.append([(exc, custom_tb or exc.__traceback__)])
|
||||
# itertools.chain is in an extension module and may be unavailable
|
||||
for it in its:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue