Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 33993:6771e1840bbc legacy-trunk
Fix pprint to be able to handle objects that don't have a __repr__
attribute. Fixes SF bug #1065456.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Mon, 15 Nov 2004 13:51:41 +0000 |
| parents | 7e3a2c274b36 |
| children | ee3e0ee1edca |
line wrap: on
line diff
--- a/Lib/pprint.py Mon Nov 15 03:50:16 2004 +0000 +++ b/Lib/pprint.py Mon Nov 15 13:51:41 2004 +0000 @@ -131,7 +131,7 @@ write = stream.write if sepLines: - r = typ.__repr__ + r = getattr(typ, "__repr__", None) if issubclass(typ, dict) and r is dict.__repr__: write('{') if self._indent_per_level > 1: @@ -229,7 +229,7 @@ write(qget(char, repr(char)[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False - r = typ.__repr__ + r = getattr(typ, "__repr__", None) if issubclass(typ, dict) and r is dict.__repr__: if not object: return "{}", True, False
