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

Method __init__

Lib/traceback.py:1044–1188  ·  view source on GitHub ↗
(self, exc_type, exc_value, exc_traceback, *, limit=None,
            lookup_lines=True, capture_locals=False, compact=False,
            max_group_width=15, max_group_depth=10, save_exc_type=True, _seen=None)

Source from the content-addressed store, hash-verified

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,
1062 capture_locals=capture_locals)
1063
1064 self._exc_type = exc_type if save_exc_type else None
1065
1066 # Capture now to permit freeing resources: only complication is in the
1067 # unofficial API _format_final_exc_line
1068 self._str = _safe_string(exc_value, 'exception')
1069 try:
1070 self.__notes__ = getattr(exc_value, '__notes__', None)
1071 except Exception as e:
1072 self.__notes__ = [
1073 f'Ignored error getting __notes__: {_safe_string(e, '__notes__', repr)}']
1074
1075 self._is_syntax_error = False
1076 self._have_exc_type = exc_type is not None
1077 if exc_type is not None:
1078 self.exc_type_qualname = exc_type.__qualname__
1079 self.exc_type_module = exc_type.__module__
1080 else:
1081 self.exc_type_qualname = None
1082 self.exc_type_module = None
1083
1084 if exc_type and issubclass(exc_type, SyntaxError):
1085 # Handle SyntaxError's specially
1086 self.filename = exc_value.filename
1087 lno = exc_value.lineno
1088 self.lineno = str(lno) if lno is not None else None
1089 end_lno = exc_value.end_lineno
1090 self.end_lineno = str(end_lno) if end_lno is not None else None
1091 self.text = exc_value.text
1092 self.offset = exc_value.offset
1093 self.end_offset = exc_value.end_offset
1094 self.msg = exc_value.msg
1095 self._is_syntax_error = True
1096 self._exc_metadata = getattr(exc_value, "_metadata", None)
1097 elif exc_type and issubclass(exc_type, ImportError) and \
1098 getattr(exc_value, "name_from", None) is not None:
1099 wrong_name = getattr(exc_value, "name_from", None)
1100 suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)
1101 if suggestion:

Callers

nothing calls this directly

Calls 15

_load_linesMethod · 0.95
setFunction · 0.85
idFunction · 0.85
_safe_stringFunction · 0.85
getattrFunction · 0.85
issubclassFunction · 0.85
strFunction · 0.85
isinstanceFunction · 0.85
TracebackExceptionClass · 0.70

Tested by

no test coverage detected