diff options
author | Robert Collins <rbtcollins@hp.com> | 2015-03-16 15:27:16 +1300 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2015-03-16 15:27:16 +1300 |
commit | bbb8ade904ea8c9b26236228e6c7029df279a523 (patch) | |
tree | ea4d3f9afc81f8b156c92aad5b8b3c1eda52b6c9 /Lib/traceback.py | |
parent | 93f4d4c1d614be8a043af35a13b0ff50d551bc7a (diff) | |
download | cpython-git-bbb8ade904ea8c9b26236228e6c7029df279a523.tar.gz |
Issue #23631: Fix traceback.format_list when a traceback has been mutated.
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index 0ac181923d..f7705cdabc 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -348,11 +348,17 @@ class StackSummary(list): This method supports the older Python API. Each tuple should be a 4-tuple with (filename, lineno, name, line) elements. """ - if isinstance(a_list, StackSummary): - return StackSummary(a_list) + # While doing a fast-path check for isinstance(a_list, StackSummary) is + # appealing, idlelib.run.cleanup_traceback and other similar code may + # break this by making arbitrary frames plain tuples, so we need to + # check on a frame by frame basis. result = StackSummary() - for filename, lineno, name, line in a_list: - result.append(FrameSummary(filename, lineno, name, line=line)) + for frame in a_list: + if isinstance(frame, FrameSummary): + result.append(frame) + else: + filename, lineno, name, line = frame + result.append(FrameSummary(filename, lineno, name, line=line)) return result def format(self): |