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

Function _strip_exception_details

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

Source from the content-addressed store, hash-verified

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

Callers 1

__runMethod · 0.85

Calls 2

findMethod · 0.45
rfindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…