Skip to content

Commit effcfd7

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

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
@@ -143,9 +143,7 @@ Module-Level Functions
143143
:ref:`traceback object <traceback-objects>` *tb*. It is useful
144144
for alternate formatting of stack traces. The optional *limit* argument has
145145
the same meaning as for :func:`print_tb`. A "pre-processed" stack trace
146-
entry is a :class:`FrameSummary` object containing attributes
147-
:attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`,
148-
:attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the
146+
entry is a :class:`FrameSummary` object with attributes representing the
149147
information that is usually printed for a stack trace.
150148

151149

@@ -177,7 +175,7 @@ Module-Level Functions
177175
.. function:: format_exception_only(exc, /[, value], *, show_group=False)
178176

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

339337
.. attribute:: exc_type
340338

341-
The class of the original traceback.
339+
The class of the original exception.
342340

343341
.. deprecated:: 3.13
344342

@@ -382,7 +380,7 @@ the module-level functions described above.
382380

383381
For syntax errors - the compiler error message.
384382

385-
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False)
383+
.. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10)
386384

387385
Capture an exception for later rendering. *limit*, *lookup_lines* and
388386
*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
@@ -70,10 +70,10 @@ def extract_tb(tb, limit=None):
7070
This is useful for alternate formatting of stack traces. If
7171
'limit' is omitted or None, all entries are extracted. A
7272
pre-processed stack trace entry is a FrameSummary object
73-
containing attributes filename, lineno, name, and line
74-
representing the information that is usually printed for a stack
75-
trace. The line is a string with leading and trailing
76-
whitespace stripped; if the source is not available it is None.
73+
representing the information that is usually printed for a
74+
stack trace. The line attribute is a string with
75+
leading and trailing whitespace stripped; if the source is not
76+
available the corresponding attribute is None.
7777
"""
7878
return StackSummary._extract_from_extended_frame_gen(
7979
_walk_tb_with_full_positions(tb), limit=limit)
@@ -251,9 +251,8 @@ def extract_stack(f=None, limit=None):
251251
252252
The return value has the same format as for extract_tb(). The
253253
optional 'f' and 'limit' arguments have the same meaning as for
254-
print_stack(). Each item in the list is a quadruple (filename,
255-
line number, function name, text), and the entries are in order
256-
from oldest to newest stack frame.
254+
print_stack(). Each item in the list is a FrameSummary object,
255+
and the entries are in order from oldest to newest stack frame.
257256
"""
258257
if f is None:
259258
f = sys._getframe().f_back
@@ -281,7 +280,7 @@ class FrameSummary:
281280
active when the frame was captured.
282281
- :attr:`name` The name of the function or method that was executing
283282
when the frame was captured.
284-
- :attr:`line` The text from the linecache module for the
283+
- :attr:`line` The text from the linecache module for the line
285284
of code that was running when the frame was captured.
286285
- :attr:`locals` Either None if locals were not supplied, or a dict
287286
mapping the name to the repr() of the variable.
@@ -951,7 +950,7 @@ def setup_positions(expr, force_valid=True):
951950
_WIDE_CHAR_SPECIFIERS = "WF"
952951

953952
def _display_width(line, offset=None):
954-
"""Calculate the extra amount of width space the given source
953+
"""Calculate the amount of width space the given source
955954
code segment might take if it were to be displayed on a fixed
956955
width output device. Supports wide unicode characters and emojis."""
957956

@@ -1037,7 +1036,7 @@ class TracebackException:
10371036
def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
10381037
lookup_lines=True, capture_locals=False, compact=False,
10391038
max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None):
1040-
# NB: we need to accept exc_traceback, exc_value, exc_traceback to
1039+
# NB: we need to accept exc_type, exc_value, exc_traceback to
10411040
# permit backwards compat with the existing API, otherwise we
10421041
# need stub thunk objects just to glue it together.
10431042
# Handle loops in __cause__ or __context__.

0 commit comments

Comments
 (0)