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

Function text_repr

IPython/core/ultratb.py:1490–1516  ·  view source on GitHub ↗

Hopefully pretty robust repr equivalent.

(value)

Source from the content-addressed store, hash-verified

1488
1489# some internal-use functions
1490def text_repr(value):
1491 """Hopefully pretty robust repr equivalent."""
1492 # this is pretty horrible but should always return *something*
1493 try:
1494 return pydoc.text.repr(value)
1495 except KeyboardInterrupt:
1496 raise
1497 except:
1498 try:
1499 return repr(value)
1500 except KeyboardInterrupt:
1501 raise
1502 except:
1503 try:
1504 # all still in an except block so we catch
1505 # getattr raising
1506 name = getattr(value, '__name__', None)
1507 if name:
1508 # ick, recursion
1509 return text_repr(name)
1510 klass = getattr(value, '__class__', None)
1511 if klass:
1512 return '%s instance' % text_repr(klass)
1513 except KeyboardInterrupt:
1514 raise
1515 except:
1516 return 'UNRECOVERABLE REPR FAILURE'
1517
1518
1519def eqrepr(value, repr=text_repr):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected