Skip to content

gh-140456: Clarify traceback source line documentation#153469

Open
harjothkhara wants to merge 2 commits into
python:mainfrom
harjothkhara:codex/gh-140456-traceback-docs
Open

gh-140456: Clarify traceback source line documentation#153469
harjothkhara wants to merge 2 commits into
python:mainfrom
harjothkhara:codex/gh-140456-traceback-docs

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

traceback.format_list() stopped printing every line when a frame's line holds more than one physical line. On the issue, serhiy-storchaka pointed out that line was never meant to hold more than one line, so this documents the real contract instead of changing behavior.

Updates the docs and the matching docstrings for format_list(), StackSummary.from_list(), StackSummary.format() and FrameSummary.line. A frame only shows all of its lines when it has column position information and an end line number past its own line number — column info by itself isn't enough, since end_lineno defaults to lineno.

Adds tests for old-style tuples and for FrameSummary with column info, without it, and with column info but no end_lineno.

No behavior change — Lib/traceback.py is docstrings only. Docs and tests, so no NEWS entry.

I used AI assistance for this and have reviewed the change.

@read-the-docs-community

read-the-docs-community Bot commented Jul 10, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33524104 | 📁 Comparing a13acfa against main (1b41c7b)

  🔍 Preview build  

1 file changed
± library/traceback.html

@harjothkhara harjothkhara force-pushed the codex/gh-140456-traceback-docs branch 2 times, most recently from 6202ef6 to 5bc4855 Compare July 10, 2026 01:14
@harjothkhara harjothkhara force-pushed the codex/gh-140456-traceback-docs branch from 5bc4855 to 67bab37 Compare July 10, 2026 01:22
Column position information alone is not enough: end_lineno defaults to
lineno, so a frame with colno/end_colno but no end_lineno still shows
only its first physical line.  Say so, and test it.
@harjothkhara harjothkhara marked this pull request as ready for review July 10, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant