Skip to content

Commit 6a5ff93

Browse files
[3.12] gh-111157: Mention __notes__ in traceback.format_exception_only docstring (GH-111158) (#111163)
gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring (GH-111158) (cherry picked from commit 5e7727b) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 552ceb2 commit 6a5ff93

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

Lib/traceback.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,11 @@ def format_exception_only(exc, /, value=_sentinel):
145145
146146
The return value is a list of strings, each ending in a newline.
147147
148-
Normally, the list contains a single string; however, for
149-
SyntaxError exceptions, it contains several lines that (when
150-
printed) display detailed information about where the syntax
151-
error occurred.
152-
153-
The message indicating which exception occurred is always the last
154-
string in the list.
155-
148+
The list contains the exception's message, which is
149+
normally a single string; however, for :exc:`SyntaxError` exceptions, it
150+
contains several lines that (when printed) display detailed information
151+
about where the syntax error occurred. Following the message, the list
152+
contains the exception's ``__notes__``.
156153
"""
157154
if value is _sentinel:
158155
value = exc
@@ -841,13 +838,13 @@ def format_exception_only(self):
841838
842839
The return value is a generator of strings, each ending in a newline.
843840
844-
Normally, the generator emits a single string; however, for
845-
SyntaxError exceptions, it emits several lines that (when
846-
printed) display detailed information about where the syntax
847-
error occurred.
848-
849-
The message indicating which exception occurred is always the last
850-
string in the output.
841+
Generator yields the exception message.
842+
For :exc:`SyntaxError` exceptions, it
843+
also yields (before the exception message)
844+
several lines that (when printed)
845+
display detailed information about where the syntax error occurred.
846+
Following the message, generator also yields
847+
all the exception's ``__notes__``.
851848
"""
852849
if self.exc_type is None:
853850
yield _format_final_exc_line(None, self._str)

0 commit comments

Comments
 (0)