You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traceback.format_list() no longer works with lines that have breaks in them:
importtracebackimportsysprint(f"Python {sys.version_info.major}.{sys.version_info.minor}")
# Frame with multiline text (source + variable annotations)frames= [('test.py', 10, 'func', 'x = foo + bar\n\t\thello\n\tworld')]
print("\nInput (3 lines):")
print(repr(frames[0][3]))
print("\nOutput from traceback.format_list():")
result=traceback.format_list(frames)[0] # Yes, it't always a 1-element list both on 3.12 adn 3.13.print(result)
Python 3.12
Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'
Output from traceback.format_list():
File "test.py", line 10, in func
x = foo + bar
hello
world
Python 3.13
Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'
Output from traceback.format_list():
File "test.py", line 10, in func
x = foo + bar
This broke bettre_exceptions on 3.13, which was fixed by formatting the traceback manually. Can we either
Revert to old behavior in 3.15 and maybe document that it was broken in 3.13 and 3.14?
It was never claimed that line can represent several physical lines. Taking into account that leading and trailing whitespace were stripped, and the line is printed with an indentation, and that an anchor was printed immediately under the line, the code never correctly supported line containing newline characters (and other control characters).
We can document that line is the single line of the code (it was not obvious after adding end_lineno). But there is no need to document the change -- because the behavior for multi-line line was not specified.
Activity
serhiy-storchaka commentedon Oct 22, 2025
It was never claimed that
linecan represent several physical lines. Taking into account that leading and trailing whitespace were stripped, and the line is printed with an indentation, and that an anchor was printed immediately under the line, the code never correctly supportedlinecontaining newline characters (and other control characters).We can document that
lineis the single line of the code (it was not obvious after addingend_lineno). But there is no need to document the change -- because the behavior for multi-linelinewas not specified.pythongh-140456: Clarify traceback source line documentation
pythongh-140456: Clarify traceback source line documentation
pythongh-140456: Clarify traceback source line documentation
pythongh-140456: Clarify traceback source line documentation
Add NEWS entry for pythongh-140456
Merge branch 'main' into codex/pythongh-140456-traceback-docs
harjothkhara commentedon Aug 23, 2026
Docs PR for this is open at #153469.
pythongh-140456: Document that FrameSummary.line is a single line
Merge branch 'main' into codex/pythongh-140456-traceback-docs