MCPcopy Index your code
hub / github.com/RustPython/RustPython / _strip_exception_details

Function _strip_exception_details

Lib/doctest.py:355–379  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

353 return '#'
354
355def _strip_exception_details(msg):
356 # Support for IGNORE_EXCEPTION_DETAIL.
357 # Get rid of everything except the exception name; in particular, drop
358 # the possibly dotted module path (if any) and the exception message (if
359 # any). We assume that a colon is never part of a dotted name, or of an
360 # exception name.
361 # E.g., given
362 # "foo.bar.MyError: la di da"
363 # return "MyError"
364 # Or for "abc.def" or "abc.def:\n" return "def".
365
366 start, end = 0, len(msg)
367 # The exception name must appear on the first line.
368 i = msg.find("\n")
369 if i >= 0:
370 end = i
371 # retain up to the first colon (if any)
372 i = msg.find(':', 0, end)
373 if i >= 0:
374 end = i
375 # retain just the exception name
376 i = msg.rfind('.', 0, end)
377 if i >= 0:
378 start = i+1
379 return msg[start: end]
380
381class _OutputRedirectingPdb(pdb.Pdb):
382 """

Callers 1

__runMethod · 0.85

Calls 3

lenFunction · 0.85
findMethod · 0.45
rfindMethod · 0.45

Tested by

no test coverage detected