Kaydet (Commit) 1b626cac authored tarafından Walter Dörwald's avatar Walter Dörwald

Fix pprint to be able to handle objects that don't have a __repr__

attribute. Fixes SF bug #1065456.
üst fdc58f23
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment