From 2151f118c2097e2a293debfc87ae8e88bbe419b4 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 20:43:34 +0200 Subject: [PATCH 01/12] Add missing 3.10/11 attributes to traceback module docs --- Doc/library/traceback.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 5c0e261b90763c..7715af6e5a6c8f 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -238,6 +238,10 @@ capture data for later printing in a lightweight fashion. A :class:`TracebackException` of the original ``__context__``. + .. attribute:: exceptions + + For exception groups - a list of :class:`TracebackException` of the original ``exceptions``. + .. attribute:: __suppress_context__ The ``__suppress_context__`` value from the original exception. @@ -266,6 +270,11 @@ capture data for later printing in a lightweight fashion. For syntax errors - the line number where the error occurred. + .. attribute:: end_lineno + + For syntax errors - the end line number where the error occurred. + Can be `None` if not present. + .. attribute:: text For syntax errors - the text where the error occurred. @@ -274,6 +283,11 @@ capture data for later printing in a lightweight fashion. For syntax errors - the offset into the text where the error occurred. + .. attribute:: end_offset + + For syntax errors - the end offset into the text where the error occurred. + Can be `None` if not present. + .. attribute:: msg For syntax errors - the compiler error message. From 67634c6bf3382de2be2c1511f430d48aaf69b47f Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 20:44:25 +0200 Subject: [PATCH 02/12] Add versionadded --- Doc/library/traceback.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 7715af6e5a6c8f..515fc0718cb81a 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -242,6 +242,8 @@ capture data for later printing in a lightweight fashion. For exception groups - a list of :class:`TracebackException` of the original ``exceptions``. + .. versionadded:: 3.11 + .. attribute:: __suppress_context__ The ``__suppress_context__`` value from the original exception. @@ -275,6 +277,8 @@ capture data for later printing in a lightweight fashion. For syntax errors - the end line number where the error occurred. Can be `None` if not present. + .. versionadded:: 3.10 + .. attribute:: text For syntax errors - the text where the error occurred. @@ -288,6 +292,8 @@ capture data for later printing in a lightweight fashion. For syntax errors - the end offset into the text where the error occurred. Can be `None` if not present. + .. versionadded:: 3.10 + .. attribute:: msg For syntax errors - the compiler error message. From 061cb4e0258ba1d2536ae2baa3480f9fa841f6f4 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 20:46:24 +0200 Subject: [PATCH 03/12] Update traceback.py --- Lib/traceback.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/traceback.py b/Lib/traceback.py index 419f6e81b5e1be..8a53c6467f23b1 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -658,6 +658,8 @@ class TracebackException: - :attr:`__cause__` A TracebackException of the original *__cause__*. - :attr:`__context__` A TracebackException of the original *__context__*. + - :attr:`exceptions` For exception groups - a list of TracebackException + of the original *exceptions*. - :attr:`__suppress_context__` The *__suppress_context__* value from the original exception. - :attr:`stack` A `StackSummary` representing the traceback. @@ -672,8 +674,8 @@ class TracebackException: occurred. - :attr:`offset` For syntax errors - the offset into the text where the error occurred. - - :attr:`end_offset` For syntax errors - the offset into the text where the - error occurred. Can be `None` if not present. + - :attr:`end_offset` For syntax errors - the end offset into the text where + the error occurred. Can be `None` if not present. - :attr:`msg` For syntax errors - the compiler error message. """ From 422161867874e7ae32c878cfda3bc21705384c60 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 20:52:11 +0200 Subject: [PATCH 04/12] Add max_group_width/depth --- Doc/library/traceback.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 515fc0718cb81a..69dc2de1e1a2d0 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -218,7 +218,7 @@ The module also defines the following classes: :class:`TracebackException` objects are created from actual exceptions to capture data for later printing in a lightweight fashion. -.. class:: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False) +.. class:: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10) Capture an exception for later rendering. *limit*, *lookup_lines* and *capture_locals* are as for the :class:`StackSummary` class. @@ -230,6 +230,11 @@ capture data for later printing in a lightweight fashion. Note that when locals are captured, they are also shown in the traceback. + *max_group_width* and *max_group_depth* control the formatting of exception + groups. The depth refers to the nesting level of the group, and the width + refers to the size of a single exception group's exceptions array. The + formatted output is truncated when either limit is exceeded. + .. attribute:: __cause__ A :class:`TracebackException` of the original ``__cause__``. @@ -343,6 +348,9 @@ capture data for later printing in a lightweight fashion. .. versionchanged:: 3.10 Added the *compact* parameter. + .. versionchanged:: 3.11 + Added the *max_group_width* and *max_group_depth* parameters. + :class:`StackSummary` Objects ----------------------------- From b0ad19d66f0bb49a4d7fb6e30e1b91308b0649fb Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 28 May 2023 19:08:42 +0000 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst new file mode 100644 index 00000000000000..548a66050ddba8 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst @@ -0,0 +1 @@ +Add missing documentation for the ``exceptions``, ``end_lineno``, and ``end_offset`` attributes of the :class:`traceback.TracebackException` class From 0ddcd6f4a65c2da3ffac5fce360b778bb518b1b0 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 28 May 2023 19:10:11 +0000 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst new file mode 100644 index 00000000000000..6564cc88455390 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst @@ -0,0 +1 @@ +Add missing documentation for the ``max_group_depth`` and ``max_group_width`` parameters to the constructor of :class:`traceback.TracebackException` class From 4113e8999dce6e88825dbcc10d2826c7016add23 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 21:28:26 +0200 Subject: [PATCH 07/12] Fix single backticks --- Doc/library/traceback.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 69dc2de1e1a2d0..db9922311f433c 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -280,7 +280,7 @@ capture data for later printing in a lightweight fashion. .. attribute:: end_lineno For syntax errors - the end line number where the error occurred. - Can be `None` if not present. + Can be ``None`` if not present. .. versionadded:: 3.10 @@ -295,7 +295,7 @@ capture data for later printing in a lightweight fashion. .. attribute:: end_offset For syntax errors - the end offset into the text where the error occurred. - Can be `None` if not present. + Can be ``None`` if not present. .. versionadded:: 3.10 From d749737f03462cd02edfb97102ff7f0a54cfc0f4 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 23:03:15 +0200 Subject: [PATCH 08/12] Remove 3.10 changes --- Doc/library/traceback.rst | 14 -------------- Lib/traceback.py | 4 ++-- .../2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst | 1 - .../2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst | 1 + ... 2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst} | 0 5 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst create mode 100644 Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst rename Misc/NEWS.d/next/Documentation/{2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst => 2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst} (100%) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index db9922311f433c..bd9aa17f41f519 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -277,13 +277,6 @@ capture data for later printing in a lightweight fashion. For syntax errors - the line number where the error occurred. - .. attribute:: end_lineno - - For syntax errors - the end line number where the error occurred. - Can be ``None`` if not present. - - .. versionadded:: 3.10 - .. attribute:: text For syntax errors - the text where the error occurred. @@ -292,13 +285,6 @@ capture data for later printing in a lightweight fashion. For syntax errors - the offset into the text where the error occurred. - .. attribute:: end_offset - - For syntax errors - the end offset into the text where the error occurred. - Can be ``None`` if not present. - - .. versionadded:: 3.10 - .. attribute:: msg For syntax errors - the compiler error message. diff --git a/Lib/traceback.py b/Lib/traceback.py index 8a53c6467f23b1..6c6d7587eed214 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -674,8 +674,8 @@ class TracebackException: occurred. - :attr:`offset` For syntax errors - the offset into the text where the error occurred. - - :attr:`end_offset` For syntax errors - the end offset into the text where - the error occurred. Can be `None` if not present. + - :attr:`end_offset` For syntax errors - the offset into the text where the + error occurred. Can be `None` if not present. - :attr:`msg` For syntax errors - the compiler error message. """ diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst deleted file mode 100644 index 548a66050ddba8..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2023-05-28-19-08-42.gh-issue-105044.j4cg7K.rst +++ /dev/null @@ -1 +0,0 @@ -Add missing documentation for the ``exceptions``, ``end_lineno``, and ``end_offset`` attributes of the :class:`traceback.TracebackException` class diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst new file mode 100644 index 00000000000000..1967f145599b61 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst @@ -0,0 +1 @@ +Add missing documentation for the ``exceptions`` attribute of the :class:`traceback.TracebackException` class diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst similarity index 100% rename from Misc/NEWS.d/next/Documentation/2023-05-28-19-10-10.gh-issue-105044.qAKRrA.rst rename to Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst From a9b786081f9b81993c29ef6cd53df2142a8c1349 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 23:04:27 +0200 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/library/traceback.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index bd9aa17f41f519..8c3506850a2dac 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -231,7 +231,7 @@ capture data for later printing in a lightweight fashion. Note that when locals are captured, they are also shown in the traceback. *max_group_width* and *max_group_depth* control the formatting of exception - groups. The depth refers to the nesting level of the group, and the width + groups (see :exc:`BaseExceptionGroup`). The depth refers to the nesting level of the group, and the width refers to the size of a single exception group's exceptions array. The formatted output is truncated when either limit is exceeded. @@ -245,7 +245,7 @@ capture data for later printing in a lightweight fashion. .. attribute:: exceptions - For exception groups - a list of :class:`TracebackException` of the original ``exceptions``. + If ``self`` represents an :exc:`ExceptionGroup` - a list of :class:`TracebackException` instances representing the nested exceptions. .. versionadded:: 3.11 From 1e049854276eaa9b8f1b402096b92fbfdce23b03 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 28 May 2023 23:37:27 +0200 Subject: [PATCH 10/12] Wrap docs to 80 chars --- Doc/library/traceback.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index 8c3506850a2dac..efd7689816a8a5 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -231,9 +231,10 @@ capture data for later printing in a lightweight fashion. Note that when locals are captured, they are also shown in the traceback. *max_group_width* and *max_group_depth* control the formatting of exception - groups (see :exc:`BaseExceptionGroup`). The depth refers to the nesting level of the group, and the width - refers to the size of a single exception group's exceptions array. The - formatted output is truncated when either limit is exceeded. + groups (see :exc:`BaseExceptionGroup`). The depth refers to the nesting + level of the group, and the width refers to the size of a single exception + group's exceptions array. The formatted output is truncated when either + limit is exceeded. .. attribute:: __cause__ @@ -245,7 +246,8 @@ capture data for later printing in a lightweight fashion. .. attribute:: exceptions - If ``self`` represents an :exc:`ExceptionGroup` - a list of :class:`TracebackException` instances representing the nested exceptions. + If ``self`` represents an :exc:`ExceptionGroup` - a list of + :class:`TracebackException` instances representing the nested exceptions. .. versionadded:: 3.11 From a9c91c7cbbc2ff4b898b19d78b52593806bbd773 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Mon, 29 May 2023 17:39:06 +0200 Subject: [PATCH 11/12] Merge changelog entries --- .../2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst | 1 - .../2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst deleted file mode 100644 index 1967f145599b61..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2023-05-28-21-00-05.gh-issue-89455.j4cg7J.rst +++ /dev/null @@ -1 +0,0 @@ -Add missing documentation for the ``exceptions`` attribute of the :class:`traceback.TracebackException` class diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst index 6564cc88455390..6cf1c76e644d34 100644 --- a/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst +++ b/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst @@ -1 +1,3 @@ -Add missing documentation for the ``max_group_depth`` and ``max_group_width`` parameters to the constructor of :class:`traceback.TracebackException` class +Add missing documentation for the ``max_group_depth`` and ``max_group_width`` +parameters and the ``exceptions`` attribute of the +:class:`traceback.TracebackException` class From 848ad9481e09018fc368339f577618b56255c6e9 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Mon, 29 May 2023 20:02:27 +0200 Subject: [PATCH 12/12] Apply suggestions from code review Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Doc/library/traceback.rst | 3 ++- Lib/traceback.py | 2 +- .../2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index efd7689816a8a5..9a04b56947a1bb 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -246,8 +246,9 @@ capture data for later printing in a lightweight fashion. .. attribute:: exceptions - If ``self`` represents an :exc:`ExceptionGroup` - a list of + If ``self`` represents an :exc:`ExceptionGroup`, this field holds a list of :class:`TracebackException` instances representing the nested exceptions. + Otherwise it is ``None``. .. versionadded:: 3.11 diff --git a/Lib/traceback.py b/Lib/traceback.py index 6c6d7587eed214..0ea77bfb94612e 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -659,7 +659,7 @@ class TracebackException: - :attr:`__cause__` A TracebackException of the original *__cause__*. - :attr:`__context__` A TracebackException of the original *__context__*. - :attr:`exceptions` For exception groups - a list of TracebackException - of the original *exceptions*. + instances for the nested *exceptions*. ``None`` for other exceptions. - :attr:`__suppress_context__` The *__suppress_context__* value from the original exception. - :attr:`stack` A `StackSummary` representing the traceback. diff --git a/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst b/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst index 6cf1c76e644d34..fdfa4357f001b5 100644 --- a/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst +++ b/Misc/NEWS.d/next/Documentation/2023-05-28-21-01-00.gh-issue-89455.qAKRrA.rst @@ -1,3 +1,3 @@ Add missing documentation for the ``max_group_depth`` and ``max_group_width`` parameters and the ``exceptions`` attribute of the -:class:`traceback.TracebackException` class +:class:`traceback.TracebackException` class.