MCPcopy Index your code
hub / github.com/python/cpython / TracebackException

Class TracebackException

Lib/traceback.py:1024–1644  ·  view source on GitHub ↗

An exception ready for rendering. The traceback module captures enough attributes from the original exception to this intermediary form to ensure that no references are held, while still being able to fully print or format it. max_group_width and max_group_depth control the formatt

Source from the content-addressed store, hash-verified

1022
1023
1024class TracebackException:
1025 """An exception ready for rendering.
1026
1027 The traceback module captures enough attributes from the original exception
1028 to this intermediary form to ensure that no references are held, while
1029 still being able to fully print or format it.
1030
1031 max_group_width and max_group_depth control the formatting of exception
1032 groups. The depth refers to the nesting level of the group, and the width
1033 refers to the size of a single exception group's exceptions array. The
1034 formatted output is truncated when either limit is exceeded.
1035
1036 Use `from_exception` to create TracebackException instances from exception
1037 objects, or the constructor to create TracebackException instances from
1038 individual components.
1039
1040 - :attr:`__cause__` A TracebackException of the original *__cause__*.
1041 - :attr:`__context__` A TracebackException of the original *__context__*.
1042 - :attr:`exceptions` For exception groups - a list of TracebackException
1043 instances for the nested *exceptions*. ``None`` for other exceptions.
1044 - :attr:`__suppress_context__` The *__suppress_context__* value from the
1045 original exception.
1046 - :attr:`stack` A `StackSummary` representing the traceback.
1047 - :attr:`exc_type` (deprecated) The class of the original traceback.
1048 - :attr:`exc_type_str` String display of exc_type
1049 - :attr:`filename` For syntax errors - the filename where the error
1050 occurred.
1051 - :attr:`lineno` For syntax errors - the linenumber where the error
1052 occurred.
1053 - :attr:`end_lineno` For syntax errors - the end linenumber where the error
1054 occurred. Can be `None` if not present.
1055 - :attr:`text` For syntax errors - the text where the error
1056 occurred.
1057 - :attr:`offset` For syntax errors - the offset into the text where the
1058 error occurred.
1059 - :attr:`end_offset` For syntax errors - the end offset into the text where
1060 the error occurred. Can be `None` if not present.
1061 - :attr:`msg` For syntax errors - the compiler error message.
1062 """
1063
1064 def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
1065 lookup_lines=True, capture_locals=False, compact=False,
1066 max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None):
1067 # NB: we need to accept exc_traceback, exc_value, exc_traceback to
1068 # permit backwards compat with the existing API, otherwise we
1069 # need stub thunk objects just to glue it together.
1070 # Handle loops in __cause__ or __context__.
1071 is_recursive_call = _seen is not None
1072 if _seen is None:
1073 _seen = set()
1074 _seen.add(id(exc_value))
1075
1076 self.max_group_width = max_group_width
1077 self.max_group_depth = max_group_depth
1078
1079 self.stack = StackSummary._extract_from_extended_frame_gen(
1080 _walk_tb_with_full_positions(exc_traceback),
1081 limit=limit, lookup_lines=lookup_lines,

Callers 4

print_exceptionFunction · 0.70
format_exceptionFunction · 0.70
format_exception_onlyFunction · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…