Skip to content

Commit 832afed

Browse files
authored
gh-145896: Fix typos and stale docstrings in the traceback module (GH-145897)
1 parent 5498eba commit 832afed

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

Doc/library/traceback.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ Module-Level Functions
147147
:ref:`traceback object <traceback-objects>` *tb*. It is useful
148148
for alternate formatting of stack traces. The optional *limit* argument has
149149
the same meaning as for :func:`print_tb`. A "pre-processed" stack trace
150-
entry is a :class:`FrameSummary` object containing attributes
151-
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
152-
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
150+
entry is a :class:`FrameSummary` object with attributes representing the
153151
information that is usually printed for a stack trace.
154152

155153

@@ -181,7 +179,7 @@ Module-Level Functions
181179
.. function:: format_exception_only(exc, /[, value], *, show_group=False)
182180

183181
Format the exception part of a traceback using an exception value such as
184-
given by :data:`sys.last_value`. The return value is a list of strings, each
182+
given by :data:`sys.last_exc`. The return value is a list of strings, each
185183
ending in a newline. The list contains the exception's message, which is
186184
normally a single string; however, for :exc:`SyntaxError` exceptions, it
187185
contains several lines that (when printed) display detailed information
@@ -347,7 +345,7 @@ the module-level functions described above.
347345

348346
.. attribute:: exc_type
349347

350-
The class of the original traceback.
348+
The class of the original exception.
351349

352350
.. deprecated:: 3.13
353351

@@ -391,7 +389,7 @@ the module-level functions described above.
391389

392390
For syntax errors - the compiler error message.
393391

394-
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False)
392+
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
395393

396394
Capture an exception for later rendering. *limit*, *lookup_lines* and
397395
*capture_locals* are as for the :class:`StackSummary` class.

Lib/traceback.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ def extract_tb(tb, limit=None):
115115
This is useful for alternate formatting of stack traces. If
116116
'limit' is omitted or None, all entries are extracted. A
117117
pre-processed stack trace entry is a FrameSummary object
118-
containing attributes filename, lineno, name, and line
119-
representing the information that is usually printed for a stack
120-
trace. The line is a string with leading and trailing
121-
whitespace stripped; if the source is not available it is None.
118+
representing the information that is usually printed for a
119+
stack trace. The line attribute is a string with
120+
leading and trailing whitespace stripped; if the source is not
121+
available the corresponding attribute is None.
122122
"""
123123
return StackSummary._extract_from_extended_frame_gen(
124124
_walk_tb_with_full_positions(tb), limit=limit)
@@ -295,9 +295,8 @@ def extract_stack(f=None, limit=None):
295295
296296
The return value has the same format as for extract_tb(). The
297297
optional 'f' and 'limit' arguments have the same meaning as for
298-
print_stack(). Each item in the list is a quadruple (filename,
299-
line number, function name, text), and the entries are in order
300-
from oldest to newest stack frame.
298+
print_stack(). Each item in the list is a FrameSummary object,
299+
and the entries are in order from oldest to newest stack frame.
301300
"""
302301
if f is None:
303302
f = sys._getframe().f_back
@@ -325,7 +324,7 @@ class FrameSummary:
325324
active when the frame was captured.
326325
- :attr:`name` The name of the function or method that was executing
327326
when the frame was captured.
328-
- :attr:`line` The text from the linecache module for the
327+
- :attr:`line` The text from the linecache module for the line
329328
of code that was running when the frame was captured.
330329
- :attr:`locals` Either None if locals were not supplied, or a dict
331330
mapping the name to the repr() of the variable.
@@ -1053,7 +1052,7 @@ def _wlen(s: str) -> int:
10531052

10541053

10551054
def _display_width(line, offset=None):
1056-
"""Calculate the extra amount of width space the given source
1055+
"""Calculate the amount of width space the given source
10571056
code segment might take if it were to be displayed on a fixed
10581057
width output device. Supports wide unicode characters and emojis."""
10591058

@@ -1134,7 +1133,7 @@ class TracebackException:
11341133
def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11351134
lookup_lines=True, capture_locals=False, compact=False,
11361135
max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None):
1137-
# NB: we need to accept exc_traceback, exc_value, exc_traceback to
1136+
# NB: we need to accept exc_type, exc_value, exc_traceback to
11381137
# permit backwards compat with the existing API, otherwise we
11391138
# need stub thunk objects just to glue it together.
11401139
# Handle loops in __cause__ or __context__.

0 commit comments

Comments
 (0)