Skip to content

Commit 17b8e35

Browse files
[3.11] gh-111157: Mention __notes__ in traceback.format_exception_only docstring (GH-111158) (#111164)
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 47670fb commit 17b8e35

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
@@ -817,13 +814,13 @@ def format_exception_only(self):
817814
818815
The return value is a generator of strings, each ending in a newline.
819816
820-
Normally, the generator emits a single string; however, for
821-
SyntaxError exceptions, it emits several lines that (when
822-
printed) display detailed information about where the syntax
823-
error occurred.
824-
825-
The message indicating which exception occurred is always the last
826-
string in the output.
817+
Generator yields the exception message.
818+
For :exc:`SyntaxError` exceptions, it
819+
also yields (before the exception message)
820+
several lines that (when printed)
821+
display detailed information about where the syntax error occurred.
822+
Following the message, generator also yields
823+
all the exception's ``__notes__``.
827824
"""
828825
if self.exc_type is None:
829826
yield _format_final_exc_line(None, self._str)

0 commit comments

Comments
 (0)