Skip to content

Commit 0bff118

Browse files
[3.14] gh-145896: Fix typos and stale docstrings in the traceback module (GH-145897) (GH-150382)
(cherry picked from commit 832afed) Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
1 parent ec4df59 commit 0bff118

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
@@ -74,10 +74,10 @@ def extract_tb(tb, limit=None):
7474
This is useful for alternate formatting of stack traces. If
7575
'limit' is omitted or None, all entries are extracted. A
7676
pre-processed stack trace entry is a FrameSummary object
77-
containing attributes filename, lineno, name, and line
78-
representing the information that is usually printed for a stack
79-
trace. The line is a string with leading and trailing
80-
whitespace stripped; if the source is not available it is None.
77+
representing the information that is usually printed for a
78+
stack trace. The line attribute is a string with
79+
leading and trailing whitespace stripped; if the source is not
80+
available the corresponding attribute is None.
8181
"""
8282
return StackSummary._extract_from_extended_frame_gen(
8383
_walk_tb_with_full_positions(tb), limit=limit)
@@ -253,9 +253,8 @@ def extract_stack(f=None, limit=None):
253253
254254
The return value has the same format as for extract_tb(). The
255255
optional 'f' and 'limit' arguments have the same meaning as for
256-
print_stack(). Each item in the list is a quadruple (filename,
257-
line number, function name, text), and the entries are in order
258-
from oldest to newest stack frame.
256+
print_stack(). Each item in the list is a FrameSummary object,
257+
and the entries are in order from oldest to newest stack frame.
259258
"""
260259
if f is None:
261260
f = sys._getframe().f_back
@@ -283,7 +282,7 @@ class FrameSummary:
283282
active when the frame was captured.
284283
- :attr:`name` The name of the function or method that was executing
285284
when the frame was captured.
286-
- :attr:`line` The text from the linecache module for the
285+
- :attr:`line` The text from the linecache module for the line
287286
of code that was running when the frame was captured.
288287
- :attr:`locals` Either None if locals were not supplied, or a dict
289288
mapping the name to the repr() of the variable.
@@ -958,7 +957,7 @@ def setup_positions(expr, force_valid=True):
958957
_WIDE_CHAR_SPECIFIERS = "WF"
959958

960959
def _display_width(line, offset=None):
961-
"""Calculate the extra amount of width space the given source
960+
"""Calculate the amount of width space the given source
962961
code segment might take if it were to be displayed on a fixed
963962
width output device. Supports wide unicode characters and emojis."""
964963

@@ -1044,7 +1043,7 @@ class TracebackException:
10441043
def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
10451044
lookup_lines=True, capture_locals=False, compact=False,
10461045
max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None):
1047-
# NB: we need to accept exc_traceback, exc_value, exc_traceback to
1046+
# NB: we need to accept exc_type, exc_value, exc_traceback to
10481047
# permit backwards compat with the existing API, otherwise we
10491048
# need stub thunk objects just to glue it together.
10501049
# Handle loops in __cause__ or __context__.

0 commit comments

Comments
 (0)