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

Function _format_final_exc_line

Lib/traceback.py:196–207  ·  view source on GitHub ↗
(etype, value, *, insert_final_newline=True, colorize=False)

Source from the content-addressed store, hash-verified

194# -- not official API but folk probably use these two functions.
195
196def _format_final_exc_line(etype, value, *, insert_final_newline=True, colorize=False):
197 valuestr = _safe_string(value, 'exception')
198 end_char = "\n" if insert_final_newline else ""
199 if colorize:
200 theme = _colorize.get_theme(force_color=True).traceback
201 else:
202 theme = _colorize.get_theme(force_no_color=True).traceback
203 if value is None or not valuestr:
204 line = f"{theme.type}{etype}{theme.reset}{end_char}"
205 else:
206 line = f"{theme.type}{etype}{theme.reset}: {theme.message}{valuestr}{theme.reset}{end_char}"
207 return line
208
209
210def _safe_string(value, what, func=str):

Callers 1

format_exception_onlyMethod · 0.85

Calls 1

_safe_stringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…