From 82f353825350007dc08898471e6bc28f33a4ef13 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 21 Oct 2023 13:13:33 +0300 Subject: [PATCH 1/4] gh-111157: Mention `__notes__` in `traceback.format_exception_only` docstring --- Lib/traceback.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index 7cc84b9c762aeb..48798b5ac56c49 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -156,7 +156,8 @@ def format_exception_only(exc, /, value=_sentinel): 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. + error occurred. Following the message, the list + contains the exception's ``__notes__``. The message indicating which exception occurred is always the last string in the list. @@ -860,7 +861,8 @@ def format_exception_only(self, *, show_group=False, _depth=0): 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. + error occurred. Following the message, the list + contains the exception's ``__notes__``. The message indicating which exception occurred is always the last string in the output. From 919d35ed50d715225a197c7314a692c52ff3bb91 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 21 Oct 2023 15:27:25 +0300 Subject: [PATCH 2/4] Better wording --- Lib/traceback.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index 48798b5ac56c49..36ce51aa29eaa3 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -153,15 +153,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. Following the message, 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__``. - - The message indicating which exception occurred is always the last - string in the list. - """ if value is _sentinel: value = exc @@ -858,14 +854,12 @@ def format_exception_only(self, *, show_group=False, _depth=0): 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. Following the message, the list - contains the exception's ``__notes__``. - - The message indicating which exception occurred is always the last - string in the output. + Generator normally yields 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, generator also emits + all exception's ``__notes__``. """ indent = 3 * _depth * ' ' From 9531e49fdac4d575d26493b2eb6eab55c2ce5a5a Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 21 Oct 2023 17:55:53 +0300 Subject: [PATCH 3/4] Wording --- Lib/traceback.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index 36ce51aa29eaa3..bc00d3b3766500 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -854,11 +854,12 @@ def format_exception_only(self, *, show_group=False, _depth=0): The return value is a generator of strings, each ending in a newline. - Generator normally yields 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, generator also emits + 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 exception's ``__notes__``. """ From cecf02b9d716962d06ae6fdd115d8b3578761f21 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:02:29 +0100 Subject: [PATCH 4/4] typo --- Lib/traceback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index bc00d3b3766500..d3c581f92ba1b8 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -860,7 +860,7 @@ def format_exception_only(self, *, show_group=False, _depth=0): several lines that (when printed) display detailed information about where the syntax error occurred. Following the message, generator also yields - all exception's ``__notes__``. + all the exception's ``__notes__``. """ indent = 3 * _depth * ' '