MCPcopy Create free account
hub / github.com/ipython/ipython / format_exception_as_a_whole

Method format_exception_as_a_whole

IPython/core/ultratb.py:1132–1162  ·  view source on GitHub ↗

Formats the header, traceback and exception message for a single exception. This may be called multiple times by Python 3 exception chaining (PEP 3134).

(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)

Source from the content-addressed store, hash-verified

1130 colorsnormal, py3compat.cast_unicode(evalue_str))]
1131
1132 def format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset):
1133 """Formats the header, traceback and exception message for a single exception.
1134
1135 This may be called multiple times by Python 3 exception chaining
1136 (PEP 3134).
1137 """
1138 # some locals
1139 orig_etype = etype
1140 try:
1141 etype = etype.__name__
1142 except AttributeError:
1143 pass
1144
1145 tb_offset = self.tb_offset if tb_offset is None else tb_offset
1146 head = self.prepare_header(etype, self.long_header)
1147 records = self.get_records(etb, number_of_lines_of_context, tb_offset)
1148
1149
1150 last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
1151
1152 frames = self.format_records(records, last_unique, recursion_repeat)
1153
1154 formatted_exception = self.format_exception(etype, evalue)
1155 if records:
1156 filepath, lnum = records[-1][1:3]
1157 filepath = os.path.abspath(filepath)
1158 ipinst = get_ipython()
1159 if ipinst is not None:
1160 ipinst.hooks.synchronize_with_editor(filepath, lnum, 0)
1161
1162 return [[head] + frames + [''.join(formatted_exception[0])]]
1163
1164 def get_records(self, etb, number_of_lines_of_context, tb_offset):
1165 try:

Callers 1

structured_tracebackMethod · 0.95

Calls 6

prepare_headerMethod · 0.95
get_recordsMethod · 0.95
format_recordsMethod · 0.95
format_exceptionMethod · 0.95
get_ipythonFunction · 0.90
find_recursionFunction · 0.85

Tested by

no test coverage detected