mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-67224: Show source lines in tracebacks when using the -c option when running Python (#111200)
This commit is contained in:
parent
3f84a19e62
commit
90a1b2859f
13 changed files with 104 additions and 36 deletions
|
|
@ -476,12 +476,11 @@ class StackSummary(list):
|
|||
gets called for every frame to be printed in the stack summary.
|
||||
"""
|
||||
row = []
|
||||
if frame_summary.filename.startswith("<python-input"):
|
||||
row.append(' File "<stdin>", line {}, in {}\n'.format(
|
||||
frame_summary.lineno, frame_summary.name))
|
||||
else:
|
||||
row.append(' File "{}", line {}, in {}\n'.format(
|
||||
frame_summary.filename, frame_summary.lineno, frame_summary.name))
|
||||
filename = frame_summary.filename
|
||||
if frame_summary.filename.startswith("<stdin>-"):
|
||||
filename = "<stdin>"
|
||||
row.append(' File "{}", line {}, in {}\n'.format(
|
||||
filename, frame_summary.lineno, frame_summary.name))
|
||||
if frame_summary.line:
|
||||
stripped_line = frame_summary.line.strip()
|
||||
row.append(' {}\n'.format(stripped_line))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue