mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
[3.6] bpo-28603: Fix formatting tracebacks for unhashable exceptions (GH-4014) (#4024)
(cherry picked from commit de86073a76
)
This commit is contained in:
parent
858ea4354f
commit
2712247ec9
9 changed files with 114 additions and 9 deletions
|
@ -203,16 +203,16 @@ def print_exception():
|
|||
seen = set()
|
||||
|
||||
def print_exc(typ, exc, tb):
|
||||
seen.add(exc)
|
||||
seen.add(id(exc))
|
||||
context = exc.__context__
|
||||
cause = exc.__cause__
|
||||
if cause is not None and cause not in seen:
|
||||
if cause is not None and id(cause) not in seen:
|
||||
print_exc(type(cause), cause, cause.__traceback__)
|
||||
print("\nThe above exception was the direct cause "
|
||||
"of the following exception:\n", file=efile)
|
||||
elif (context is not None and
|
||||
not exc.__suppress_context__ and
|
||||
context not in seen):
|
||||
id(context) not in seen):
|
||||
print_exc(type(context), context, context.__traceback__)
|
||||
print("\nDuring handling of the above exception, "
|
||||
"another exception occurred:\n", file=efile)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue