MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / TracebackException

Class TracebackException

tools/python-3.11.9-amd64/Lib/traceback.py:674–1022  ·  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 f

Source from the content-addressed store, hash-verified

672
673
674class TracebackException:
675 """An exception ready for rendering.
676
677 The traceback module captures enough attributes from the original exception
678 to this intermediary form to ensure that no references are held, while
679 still being able to fully print or format it.
680
681 max_group_width and max_group_depth control the formatting of exception
682 groups. The depth refers to the nesting level of the group, and the width
683 refers to the size of a single exception group's exceptions array. The
684 formatted output is truncated when either limit is exceeded.
685
686 Use `from_exception` to create TracebackException instances from exception
687 objects, or the constructor to create TracebackException instances from
688 individual components.
689
690 - :attr:`__cause__` A TracebackException of the original *__cause__*.
691 - :attr:`__context__` A TracebackException of the original *__context__*.
692 - :attr:`exceptions` For exception groups - a list of TracebackException
693 instances for the nested *exceptions*. ``None`` for other exceptions.
694 - :attr:`__suppress_context__` The *__suppress_context__* value from the
695 original exception.
696 - :attr:`stack` A `StackSummary` representing the traceback.
697 - :attr:`exc_type` The class of the original traceback.
698 - :attr:`filename` For syntax errors - the filename where the error
699 occurred.
700 - :attr:`lineno` For syntax errors - the linenumber where the error
701 occurred.
702 - :attr:`end_lineno` For syntax errors - the end linenumber where the error
703 occurred. Can be `None` if not present.
704 - :attr:`text` For syntax errors - the text where the error
705 occurred.
706 - :attr:`offset` For syntax errors - the offset into the text where the
707 error occurred.
708 - :attr:`end_offset` For syntax errors - the end offset into the text where
709 the error occurred. Can be `None` if not present.
710 - :attr:`msg` For syntax errors - the compiler error message.
711 """
712
713 def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
714 lookup_lines=True, capture_locals=False, compact=False,
715 max_group_width=15, max_group_depth=10, _seen=None):
716 # NB: we need to accept exc_traceback, exc_value, exc_traceback to
717 # permit backwards compat with the existing API, otherwise we
718 # need stub thunk objects just to glue it together.
719 # Handle loops in __cause__ or __context__.
720 is_recursive_call = _seen is not None
721 if _seen is None:
722 _seen = set()
723 _seen.add(id(exc_value))
724
725 self.max_group_width = max_group_width
726 self.max_group_depth = max_group_depth
727
728 self.stack = StackSummary._extract_from_extended_frame_gen(
729 _walk_tb_with_full_positions(exc_traceback),
730 limit=limit, lookup_lines=lookup_lines,
731 capture_locals=capture_locals)

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