Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Lib/test/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -3431,6 +3431,23 @@ def test_format_smoke(self):
[' File "foo.py", line 1, in fred\n line\n'],
s.format())

def test_print_list_matches_format_list(self):
frame = traceback.FrameSummary('foo.py', 1, 'fred', line='line')
inputs = [
('tuple', [('foo.py', 1, 'fred', 'line')]),
('FrameSummary', [frame]),
('StackSummary',
traceback.StackSummary.from_list([('foo.py', 1, 'fred', 'line')])),
]
for input_type, extracted_list in inputs:
with self.subTest(input_type=input_type):
file = StringIO()
traceback.print_list(extracted_list, file=file)
self.assertEqual(
file.getvalue(),
''.join(traceback.format_list(extracted_list)),
)

def test_locals(self):
linecache.updatecache('/foo.py', globals())
c = test_code('/foo.py', 'method')
Expand Down
2 changes: 1 addition & 1 deletion Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def print_list(extracted_list, file=None):
extract_stack() as a formatted stack trace to the given file."""
if file is None:
file = sys.stderr
for item in StackSummary.from_list(extracted_list).format():
for item in format_list(extracted_list):
print(item, file=file, end="")

def format_list(extracted_list):
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Laura Creighton
Nick Crews
Tyler Crompton
Simon Cross
Basil Crow
Felipe Cruz
Drew Csillag
Alessandro Cucci
Expand Down
Loading