diff options
author | Irit Katriel <iritkatriel@yahoo.com> | 2021-01-15 02:45:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 02:45:02 (GMT) |
commit | 4c94d74152a511d977fe26a4f3a32b7352ba9024 (patch) | |
tree | cc0cb73d6512b874ae0886ee94aa0acce1c54488 /Doc/library/traceback.rst | |
parent | e5fe509054183bed9aef42c92da8407d339e8af8 (diff) | |
download | cpython-4c94d74152a511d977fe26a4f3a32b7352ba9024.zip cpython-4c94d74152a511d977fe26a4f3a32b7352ba9024.tar.gz cpython-4c94d74152a511d977fe26a4f3a32b7352ba9024.tar.bz2 |
bpo-42877: add the 'compact' param to TracebackException's __init__ (#24179)
Use it to reduce the time and memory taken up by several of traceback's module-level functions.
Diffstat (limited to 'Doc/library/traceback.rst')
-rw-r--r-- | Doc/library/traceback.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst index c233f18..e938dd5 100644 --- a/Doc/library/traceback.rst +++ b/Doc/library/traceback.rst @@ -212,11 +212,16 @@ 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) +.. class:: TracebackException(exc_type, exc_value, exc_traceback, *, limit=None, lookup_lines=True, capture_locals=False, compact=False) Capture an exception for later rendering. *limit*, *lookup_lines* and *capture_locals* are as for the :class:`StackSummary` class. + If *compact* is true, only data that is required by :class:`TracebackException`'s + ``format`` method is saved in the class attributes. In particular, the + ``__context__`` field is calculated only if ``__cause__`` is ``None`` and + ``__suppress_context__`` is false. + Note that when locals are captured, they are also shown in the traceback. .. attribute:: __cause__ @@ -294,6 +299,9 @@ capture data for later printing in a lightweight fashion. The message indicating which exception occurred is always the last string in the output. + .. versionchanged:: 3.10 + Added the *compact* parameter. + :class:`StackSummary` Objects ----------------------------- |