diff options
author | Walter Dörwald <walter@livinglogic.de> | 2004-11-15 13:51:41 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2004-11-15 13:51:41 (GMT) |
commit | 1b626cac734c7995849ce4b5d694edbd89e44c4a (patch) | |
tree | ff4938635e36f22fac1254a6ed01a8df7ae6d3e9 /Lib/pprint.py | |
parent | fdc58f2391a4721310702ea5ada7ac515d32fb0a (diff) | |
download | cpython-1b626cac734c7995849ce4b5d694edbd89e44c4a.zip cpython-1b626cac734c7995849ce4b5d694edbd89e44c4a.tar.gz cpython-1b626cac734c7995849ce4b5d694edbd89e44c4a.tar.bz2 |
Fix pprint to be able to handle objects that don't have a __repr__
attribute. Fixes SF bug #1065456.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r-- | Lib/pprint.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py index e92b639..da6ab1a 100644 --- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -131,7 +131,7 @@ class PrettyPrinter: 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 @@ def _safe_repr(object, context, maxlevels, level): 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 |