MCPcopy Index your code
hub / github.com/RustPython/RustPython / TracebackException

Class TracebackException

Lib/traceback.py:1004–1575  ·  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

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