MCPcopy Create free account
hub / github.com/RustPython/RustPython / _format_final_exc_line

Function _format_final_exc_line

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

Source from the content-addressed store, hash-verified

184# -- not official API but folk probably use these two functions.
185
186def _format_final_exc_line(etype, value, *, insert_final_newline=True, colorize=False):
187 valuestr = _safe_string(value, 'exception')
188 end_char = "\n" if insert_final_newline else ""
189 if colorize:
190 theme = _colorize.get_theme(force_color=True).traceback
191 else:
192 theme = _colorize.get_theme(force_no_color=True).traceback
193 if value is None or not valuestr:
194 line = f"{theme.type}{etype}{theme.reset}{end_char}"
195 else:
196 line = f"{theme.type}{etype}{theme.reset}: {theme.message}{valuestr}{theme.reset}{end_char}"
197 return line
198
199
200def _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