gh-145896: Fix typos and stale docstrings in the traceback module (GH-145897)

This commit is contained in:
devdanzin 2026-05-25 06:45:02 -03:00 committed by GitHub
parent 5498eba545
commit 832afeddce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 16 deletions

View file

@ -147,9 +147,7 @@ Module-Level Functions
:ref:`traceback object <traceback-objects>` *tb*. It is useful
for alternate formatting of stack traces. The optional *limit* argument has
the same meaning as for :func:`print_tb`. A "pre-processed" stack trace
entry is a :class:`FrameSummary` object containing attributes
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
entry is a :class:`FrameSummary` object with attributes representing the
information that is usually printed for a stack trace.
@ -181,7 +179,7 @@ Module-Level Functions
.. function:: format_exception_only(exc, /[, value], *, show_group=False)
Format the exception part of a traceback using an exception value such as
given by :data:`sys.last_value`. The return value is a list of strings, each
given by :data:`sys.last_exc`. The return value is a list of strings, each
ending in a newline. The list contains the exception's message, which is
normally a single string; however, for :exc:`SyntaxError` exceptions, it
contains several lines that (when printed) display detailed information
@ -347,7 +345,7 @@ the module-level functions described above.
.. attribute:: exc_type
The class of the original traceback.
The class of the original exception.
.. deprecated:: 3.13
@ -391,7 +389,7 @@ the module-level functions described above.
For syntax errors - the compiler error message.
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False)
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
Capture an exception for later rendering. *limit*, *lookup_lines* and
*capture_locals* are as for the :class:`StackSummary` class.

View file

@ -115,10 +115,10 @@ def extract_tb(tb, limit=None):
This is useful for alternate formatting of stack traces. If
'limit' is omitted or None, all entries are extracted. A
pre-processed stack trace entry is a FrameSummary object
containing attributes filename, lineno, name, and line
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.
representing the information that is usually printed for a
stack trace. The line attribute is a string with
leading and trailing whitespace stripped; if the source is not
available the corresponding attribute is None.
"""
return StackSummary._extract_from_extended_frame_gen(
_walk_tb_with_full_positions(tb), limit=limit)
@ -295,9 +295,8 @@ def extract_stack(f=None, limit=None):
The return value has the same format as for extract_tb(). The
optional 'f' and 'limit' arguments have the same meaning as for
print_stack(). Each item in the list is a quadruple (filename,
line number, function name, text), and the entries are in order
from oldest to newest stack frame.
print_stack(). Each item in the list is a FrameSummary object,
and the entries are in order from oldest to newest stack frame.
"""
if f is None:
f = sys._getframe().f_back
@ -325,7 +324,7 @@ class FrameSummary:
active when the frame was captured.
- :attr:`name` The name of the function or method that was executing
when the frame was captured.
- :attr:`line` The text from the linecache module for the
- :attr:`line` The text from the linecache module for the line
of code that was running when the frame was captured.
- :attr:`locals` Either None if locals were not supplied, or a dict
mapping the name to the repr() of the variable.
@ -1053,7 +1052,7 @@ def _wlen(s: str) -> int:
def _display_width(line, offset=None):
"""Calculate the extra amount of width space the given source
"""Calculate the amount of width space the given source
code segment might take if it were to be displayed on a fixed
width output device. Supports wide unicode characters and emojis."""
@ -1134,7 +1133,7 @@ class TracebackException:
def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
lookup_lines=True, capture_locals=False, compact=False,
max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None):
# NB: we need to accept exc_traceback, exc_value, exc_traceback to
# NB: we need to accept exc_type, exc_value, exc_traceback to
# permit backwards compat with the existing API, otherwise we
# need stub thunk objects just to glue it together.
# Handle loops in __cause__ or __context__.