]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 21 Oct 2023 17:06:51 +0000 (19:06 +0200)
committerGitHub <noreply@github.com>
Sat, 21 Oct 2023 17:06:51 +0000 (18:06 +0100)
gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring (GH-111158)
(cherry picked from commit 5e7727b05232b43589d177c15263d7f4f8c584a0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/traceback.py

index d3edd3a63efed91e9620d941702326b27d338a8d..0e229553cb5d253f2e24da31c3c33c0fbd2a2c8f 100644 (file)
@@ -145,14 +145,11 @@ def format_exception_only(exc, /, value=_sentinel):
 
     The return value is a list of strings, each ending in a newline.
 
-    Normally, the list contains a single string; however, for
-    SyntaxError exceptions, it contains several lines that (when
-    printed) display detailed information about where the syntax
-    error occurred.
-
-    The message indicating which exception occurred is always the last
-    string in the list.
-
+    The list contains the exception's message, which is
+    normally a single string; however, for :exc:`SyntaxError` exceptions, it
+    contains several lines that (when printed) display detailed information
+    about where the syntax error occurred. Following the message, the list
+    contains the exception's ``__notes__``.
     """
     if value is _sentinel:
         value = exc
@@ -817,13 +814,13 @@ class TracebackException:
 
         The return value is a generator of strings, each ending in a newline.
 
-        Normally, the generator emits a single string; however, for
-        SyntaxError exceptions, it emits several lines that (when
-        printed) display detailed information about where the syntax
-        error occurred.
-
-        The message indicating which exception occurred is always the last
-        string in the output.
+        Generator yields the exception message.
+        For :exc:`SyntaxError` exceptions, it
+        also yields (before the exception message)
+        several lines that (when printed)
+        display detailed information about where the syntax error occurred.
+        Following the message, generator also yields
+        all the exception's ``__notes__``.
         """
         if self.exc_type is None:
             yield _format_final_exc_line(None, self._str)