Skip to content

Commit 6794526

Browse files
[3.12] GH-89455: Add missing attributes (added in 3.11) to traceback module docs (GH-105044) (#105066)
GH-89455: Add missing attributes (added in 3.11) to traceback module docs (GH-105044) (cherry picked from commit 39f6a04) Co-authored-by: Jakub Kuczys <[email protected]>
1 parent 56722ef commit 6794526

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Doc/library/traceback.rst

+18-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ The module also defines the following classes:
218218
:class:`TracebackException` objects are created from actual exceptions to
219219
capture data for later printing in a lightweight fashion.
220220

221-
.. class:: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False)
221+
.. 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)
222222

223223
Capture an exception for later rendering. *limit*, *lookup_lines* and
224224
*capture_locals* are as for the :class:`StackSummary` class.
@@ -230,6 +230,12 @@ capture data for later printing in a lightweight fashion.
230230

231231
Note that when locals are captured, they are also shown in the traceback.
232232

233+
*max_group_width* and *max_group_depth* control the formatting of exception
234+
groups (see :exc:`BaseExceptionGroup`). The depth refers to the nesting
235+
level of the group, and the width refers to the size of a single exception
236+
group's exceptions array. The formatted output is truncated when either
237+
limit is exceeded.
238+
233239
.. attribute:: __cause__
234240

235241
A :class:`TracebackException` of the original ``__cause__``.
@@ -238,6 +244,14 @@ capture data for later printing in a lightweight fashion.
238244

239245
A :class:`TracebackException` of the original ``__context__``.
240246

247+
.. attribute:: exceptions
248+
249+
If ``self`` represents an :exc:`ExceptionGroup`, this field holds a list of
250+
:class:`TracebackException` instances representing the nested exceptions.
251+
Otherwise it is ``None``.
252+
253+
.. versionadded:: 3.11
254+
241255
.. attribute:: __suppress_context__
242256

243257
The ``__suppress_context__`` value from the original exception.
@@ -323,6 +337,9 @@ capture data for later printing in a lightweight fashion.
323337
.. versionchanged:: 3.10
324338
Added the *compact* parameter.
325339

340+
.. versionchanged:: 3.11
341+
Added the *max_group_width* and *max_group_depth* parameters.
342+
326343

327344
:class:`StackSummary` Objects
328345
-----------------------------

Lib/traceback.py

+2
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ class TracebackException:
658658
659659
- :attr:`__cause__` A TracebackException of the original *__cause__*.
660660
- :attr:`__context__` A TracebackException of the original *__context__*.
661+
- :attr:`exceptions` For exception groups - a list of TracebackException
662+
instances for the nested *exceptions*. ``None`` for other exceptions.
661663
- :attr:`__suppress_context__` The *__suppress_context__* value from the
662664
original exception.
663665
- :attr:`stack` A `StackSummary` representing the traceback.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add missing documentation for the ``max_group_depth`` and ``max_group_width``
2+
parameters and the ``exceptions`` attribute of the
3+
:class:`traceback.TracebackException` class.

0 commit comments

Comments
 (0)