summaryrefslogtreecommitdiffstats
path: root/Lib/traceback.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-10-26 06:17:28 (GMT)
committerGitHub <noreply@github.com>2023-10-26 06:17:28 (GMT)
commit90a1b2859f99a4b07da6c46b99759444e3cefbfa (patch)
treee7ef4674c8e573906cfab0f3a3f096ac3fe4862d /Lib/traceback.py
parent3f84a19e6291db682fc9a570e7612e80e2ffbbb5 (diff)
downloadcpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.zip
cpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.tar.gz
cpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.tar.bz2
gh-67224: Show source lines in tracebacks when using the -c option when running Python (#111200)
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r--Lib/traceback.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index d3c581f..4f0dff9 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -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))