MCPcopy Create free account
hub / github.com/ipython/ipython / _modify_str_or_docstring

Function _modify_str_or_docstring

IPython/utils/py3compat.py:42–60  ·  view source on GitHub ↗
(str_change_func)

Source from the content-addressed store, hash-verified

40 return buf
41
42def _modify_str_or_docstring(str_change_func):
43 @functools.wraps(str_change_func)
44 def wrapper(func_or_str):
45 if isinstance(func_or_str, (str,)):
46 func = None
47 doc = func_or_str
48 else:
49 func = func_or_str
50 doc = func.__doc__
51
52 # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly
53 if doc is not None:
54 doc = str_change_func(doc)
55
56 if func:
57 func.__doc__ = doc
58 return func
59 return doc
60 return wrapper
61
62def safe_unicode(e):
63 """unicode(e) with various fallbacks. Used for exceptions, which may not be

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected