8000 [3.11] gh-109184: update traceback module doc w.r.t notes (message is… · python/cpython@5681cd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5681cd1

Browse files
authored
[3.11] gh-109184: update traceback module doc w.r.t notes (message is no longer always at the end) (#109201) (#109336)
gh-109184: update traceback module doc w.r.t notes (message is no longer always at the end) (#109201) (cherry picked from commit 0e76cc3)
1 parent b4c1cf9 commit 5681cd1

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Doc/library/traceback.rst

Lines changed: 21 additions & 20 deletions
9AC3
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ The module defines the following functions:
140140

141141
Format the exception part of a traceback using an exception value such as
142142
given by ``sys.last_value``. The return value is a list of strings, each
143-
ending in a newline. Normally, the list contains a single string; however,
144-
for :exc:`SyntaxError` exceptions, it contains several lines that (when
145-
printed) display detailed information about where the syntax error occurred.
146-
The message indicating which exception occurred is the always last string in
147-
the list.
143+
ending in a newline. The list contains the exception's message, which is
144+
normally a single string; however, for :exc:`SyntaxError` exceptions, it
145+
contains several lines that (when printed) display detailed information
146+
about where the syntax error occurred. Following the message, the list
147+
contains the exception's :attr:`notes <BaseException.__notes__>`.
148148

149149
Since Python 3.10, instead of passing *value*, an exception object
150150
can be passed as the first argument. If *value* is provided, the first
@@ -154,6 +154,9 @@ The module defines the following functions:
154154
The *etype* parameter has been renamed to *exc* and is now
155155
positional-only.
156156

157+
.. versionchanged:: 3.11
158+
The returned list now includes any notes attached to the exception.
159+
157160

158161
.. function:: format_exception(exc, /[, value, tb], limit=None, chain=True)
159162

@@ -236,6 +239,12 @@ capture data for later printing in a lightweight fashion.
236239
group's exceptions array. The formatted output is truncated when either
237240
limit is exceeded.
238241

242+
.. versionchanged:: 3.10
243+
Added the *compact* parameter.
244+
245+
.. versionchanged:: 3.11
246+
Added the *max_group_width* and *max_group_depth* parameters.
247+
239248
.. attribute:: __cause__
240249

241250
A :class:`TracebackException` of the original ``__cause__``.
@@ -331,28 +340,20 @@ capture data for later printing in a lightweight fashion.
331340
some containing internal newlines. :func:`~traceback.print_exception`
332341
is a wrapper around this method which just prints the lines to a file.
333342

334-
The message indicating which exception occurred is always the last
335-
string in the output.
336-
337343
.. method:: format_exception_only()
338344

339345
Format the exception part of the traceback.
340346

341347
The return value is a generator of strings, each ending in a newline.
342348

343-
Normally, the generator emits a single string; however, for
344-
:exc:`SyntaxError` exceptions, it emits several lines that (when
345-
printed) display detailed information about where the syntax
346-
error occurred.
347-
348-
The message indicating which exception occurred is always the last
349-
string in the output.
349+
The generator emits the exception's message followed by its notes
350+
(if it has any). The exception message is normally a single string;
351+
however, for :exc:`SyntaxError` exceptions, it consists of several
352+
lines that (when printed) display detailed information about where
353+
the syntax error occurred.
350354

351-
.. versionchanged:: 3.10
352-
Added the *compact* parameter.
353-
354-
.. versionchanged:: 3.11
355-
Added the *max_group_width* and *max_group_depth* parameters.
355+
.. versionchanged:: 3.11
356+
The exception's notes are now included in the output.
356357

357358

358359
:class:`StackSummary` Objects

0 commit comments

Comments
 (0)
0