MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _strip_exception_details

Function _strip_exception_details

tools/python-3.11.9-amd64/Lib/doctest.py:328–352  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

326 return '#'
327
328def _strip_exception_details(msg):
329 # Support for IGNORE_EXCEPTION_DETAIL.
330 # Get rid of everything except the exception name; in particular, drop
331 # the possibly dotted module path (if any) and the exception message (if
332 # any). We assume that a colon is never part of a dotted name, or of an
333 # exception name.
334 # E.g., given
335 # "foo.bar.MyError: la di da"
336 # return "MyError"
337 # Or for "abc.def" or "abc.def:\n" return "def".
338
339 start, end = 0, len(msg)
340 # The exception name must appear on the first line.
341 i = msg.find("\n")
342 if i >= 0:
343 end = i
344 # retain up to the first colon (if any)
345 i = msg.find(':', 0, end)
346 if i >= 0:
347 end = i
348 # retain just the exception name
349 i = msg.rfind('.', 0, end)
350 if i >= 0:
351 start = i+1
352 return msg[start: end]
353
354class _OutputRedirectingPdb(pdb.Pdb):
355 """

Callers 1

__runMethod · 0.85

Calls 2

rfindMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected