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

Function format_exception

Lib/traceback.py:156–169  ·  view source on GitHub ↗

Format a stack trace and the exception information. The arguments have the same meaning as the corresponding arguments to print_exception(). The return value is a list of strings, each ending in a newline and some containing internal newlines. When these lines are concatenated and

(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
                     chain=True, **kwargs)

Source from the content-addressed store, hash-verified

154
155
156def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
157 chain=True, **kwargs):
158 """Format a stack trace and the exception information.
159
160 The arguments have the same meaning as the corresponding arguments
161 to print_exception(). The return value is a list of strings, each
162 ending in a newline and some containing internal newlines. When
163 these lines are concatenated and printed, exactly the same text is
164 printed as does print_exception().
165 """
166 colorize = kwargs.get("colorize", False)
167 value, tb = _parse_value_tb(exc, value, tb)
168 te = TracebackException(type(value), value, tb, limit=limit, compact=True)
169 return list(te.format(chain=chain, colorize=colorize))
170
171
172def format_exception_only(exc, /, value=_sentinel, *, show_group=False, **kwargs):

Callers 5

__init__Method · 0.90
runMethod · 0.90
format_excFunction · 0.85

Calls 5

formatMethod · 0.95
_parse_value_tbFunction · 0.85
listClass · 0.85
TracebackExceptionClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…