Skip to content

gh-145896: Fix typos and stale docstrings in Lib/traceback.py#145897

Open
devdanzin wants to merge 6 commits into
python:mainfrom
devdanzin:traceback_typos
Open

gh-145896: Fix typos and stale docstrings in Lib/traceback.py#145897
devdanzin wants to merge 6 commits into
python:mainfrom
devdanzin:traceback_typos

Conversation

@devdanzin
Copy link
Copy Markdown
Member

@devdanzin devdanzin commented Mar 13, 2026

This PR fixes some typos and stale docstrings, as described by Claude Code:

  • Fix stale extract_tb() docstring: add end_lineno, colno, and end_colno to the listed FrameSummary attributes (available since 3.11)
  • Fix stale extract_stack() docstring: replace outdated "quadruple (filename, line number, function name, text)" with "FrameSummary object" (stale since 3.5)
  • Fix broken grammar in FrameSummary class docstring: "for the of code""for the code"
  • Fix inaccurate _display_width() docstring: "extra amount of width""amount of width" (the function returns total display width, not a delta)
  • Fix copy-paste typo in TracebackException.__init__ comment: "exc_traceback, exc_value, exc_traceback""exc_type, exc_value, exc_traceback"

Comment thread Lib/traceback.py Outdated
Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also check that any public doc matches this one (or is as long as the internal one) please?

@devdanzin
Copy link
Copy Markdown
Member Author

Not sure what you mean by "is as long as the internal one", but I've corrected the same staleness and some typos in the traceback public documentation.

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Mar 22, 2026

By "as long as", I meant that we were precise enough in the public docs

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 8, 2026
@serhiy-storchaka serhiy-storchaka self-requested a review May 23, 2026 09:04
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM. I suggest to remove lists of FrameSummary's attribute names where we have a reference to FrameSummary,

Comment thread Doc/library/traceback.rst Outdated
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
:attr:`~FrameSummary.name`, :attr:`~FrameSummary.line`,
:attr:`~FrameSummary.end_lineno`, :attr:`~FrameSummary.colno`, and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct, because end_lineno, colno and end_colno are not printed for a stack trace. They are used to draw the caret and underscores, but only values mentioned above are directly printed.

I do not think it is worth to enumerate the printed attributes here. We have a reference to FrameSummary which contains descriptions of all attributes. I think we can remove all attribute names here.

Comment thread Lib/traceback.py Outdated
representing the information that is usually printed for a stack
trace. The line is a string with leading and trailing
whitespace stripped; if the source is not available it is None.
containing attributes filename, lineno, name, line, end_lineno,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, I suggest to remove the enumeration of attributes. They are available in the FrameSummary docs.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 24, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32828306 | 📁 Comparing 9cc4bc6 against main (a38804b)

  🔍 Preview build  

1 file changed
± library/traceback.html

@devdanzin
Copy link
Copy Markdown
Member Author

Thank for the review!

I've removed the enumerations and adapted the wording so e.g. the reference to "line" makes it clear it's an attribute.

I've avoided reflowing the text as per Bénédikt's request (makes it easier to review), please let me know whether I should reflow for the final commit.

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants