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

Function print_exception

Lib/traceback.py:128–143  ·  view source on GitHub ↗

Print exception up to 'limit' stack trace entries from 'tb' to 'file'. This differs from print_tb() in the following ways: (1) if traceback is not None, it prints a header "Traceback (most recent call last):"; (2) it prints the exception type and value after the stack trace; (3) if

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

Source from the content-addressed store, hash-verified

126
127
128def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
129 file=None, chain=True, **kwargs):
130 """Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
131
132 This differs from print_tb() in the following ways: (1) if
133 traceback is not None, it prints a header "Traceback (most recent
134 call last):"; (2) it prints the exception type and value after the
135 stack trace; (3) if type is SyntaxError and value has the
136 appropriate format, it prints the line where the syntax error
137 occurred with a caret on the next line indicating the approximate
138 position of the error.
139 """
140 colorize = kwargs.get("colorize", False)
141 value, tb = _parse_value_tb(exc, value, tb)
142 te = TracebackException(type(value), value, tb, limit=limit, compact=True)
143 te.print(file=file, chain=chain, colorize=colorize)
144
145
146BUILTIN_EXCEPTION_LIMIT = object()

Callers 4

log_exceptionMethod · 0.90
_print_exception_bltinFunction · 0.70
print_excFunction · 0.70
print_lastFunction · 0.70

Calls 4

printMethod · 0.95
_parse_value_tbFunction · 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…