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

Function safe_unicode

IPython/utils/py3compat.py:62–76  ·  view source on GitHub ↗

unicode(e) with various fallbacks. Used for exceptions, which may not be safe to call unicode() on.

(e)

Source from the content-addressed store, hash-verified

60 return wrapper
61
62def safe_unicode(e):
63 """unicode(e) with various fallbacks. Used for exceptions, which may not be
64 safe to call unicode() on.
65 """
66 try:
67 return str(e)
68 except UnicodeError:
69 pass
70
71 try:
72 return repr(e)
73 except UnicodeError:
74 pass
75
76 return u'Unrecoverably corrupt evalue'
77
78# shutil.which from Python 3.4
79def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected