Hopefully pretty robust repr equivalent.
(value)
| 1488 | |
| 1489 | # some internal-use functions |
| 1490 | def 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 | |
| 1519 | def eqrepr(value, repr=text_repr): |
nothing calls this directly
no outgoing calls
no test coverage detected