diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-28 16:12:28 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-11-28 16:12:28 (GMT) |
commit | 7b0d4a238f2a69747ed570f8bfb51fb31315eba9 (patch) | |
tree | 0e1ea6c39a6ce48f33b1358992f26d3e5ce1081a /Lib/traceback.py | |
parent | 1fc0d2b364b144e501615cf82e998beb87733607 (diff) | |
download | cpython-7b0d4a238f2a69747ed570f8bfb51fb31315eba9.zip cpython-7b0d4a238f2a69747ed570f8bfb51fb31315eba9.tar.gz cpython-7b0d4a238f2a69747ed570f8bfb51fb31315eba9.tar.bz2 |
Issue #4486: When an exception has an explicit cause, do not print its implicit context too.
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index c0d8061..8d4e96e 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -120,13 +120,14 @@ def _iter_chain(exc, custom_tb=None, seen=None): seen.add(exc) its = [] cause = exc.__cause__ - context = exc.__context__ if cause is not None and cause not in seen: its.append(_iter_chain(cause, None, seen)) its.append([(_cause_message, None)]) - if context is not None and context is not cause and context not in seen: - its.append(_iter_chain(context, None, seen)) - its.append([(_context_message, None)]) + else: + 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)]) its.append([(exc, custom_tb or exc.__traceback__)]) # itertools.chain is in an extension module and may be unavailable for it in its: |