Commit eae01940 authored by Martin v. Löwis's avatar Martin v. Löwis

Revert 1.25, as overloaded __repr__ is not considered.

parent e7563632
...@@ -130,7 +130,7 @@ class PrettyPrinter: ...@@ -130,7 +130,7 @@ class PrettyPrinter:
write = stream.write write = stream.write
if sepLines: if sepLines:
if issubclass(typ, dict): if typ is dict:
write('{') write('{')
if self._indent_per_level > 1: if self._indent_per_level > 1:
write((self._indent_per_level - 1) * ' ') write((self._indent_per_level - 1) * ' ')
...@@ -157,8 +157,8 @@ class PrettyPrinter: ...@@ -157,8 +157,8 @@ class PrettyPrinter:
write('}') write('}')
return return
if issubclass(typ, list) or issubclass(typ, tuple): if typ is list or typ is tuple:
if issubclass(typ, list): if typ is list:
write('[') write('[')
endchar = ']' endchar = ']'
else: else:
...@@ -179,7 +179,7 @@ class PrettyPrinter: ...@@ -179,7 +179,7 @@ class PrettyPrinter:
allowance + 1, context, level) allowance + 1, context, level)
indent = indent - self._indent_per_level indent = indent - self._indent_per_level
del context[objid] del context[objid]
if issubclass(typ, tuple) and length == 1: if typ is tuple and length == 1:
write(',') write(',')
write(endchar) write(endchar)
return return
...@@ -207,7 +207,7 @@ class PrettyPrinter: ...@@ -207,7 +207,7 @@ class PrettyPrinter:
def _safe_repr(object, context, maxlevels, level): def _safe_repr(object, context, maxlevels, level):
typ = _type(object) typ = _type(object)
if issubclass(typ, basestring): if typ is str:
if 'locale' not in _sys.modules: if 'locale' not in _sys.modules:
return `object`, True, False return `object`, True, False
if "'" in object and '"' not in object: if "'" in object and '"' not in object:
...@@ -226,7 +226,7 @@ def _safe_repr(object, context, maxlevels, level): ...@@ -226,7 +226,7 @@ def _safe_repr(object, context, maxlevels, level):
write(qget(char, `char`[1:-1])) write(qget(char, `char`[1:-1]))
return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
if issubclass(typ, dict): if typ is dict:
if not object: if not object:
return "{}", True, False return "{}", True, False
objid = _id(object) objid = _id(object)
...@@ -251,8 +251,8 @@ def _safe_repr(object, context, maxlevels, level): ...@@ -251,8 +251,8 @@ def _safe_repr(object, context, maxlevels, level):
del context[objid] del context[objid]
return "{%s}" % _commajoin(components), readable, recursive return "{%s}" % _commajoin(components), readable, recursive
if issubclass(typ, list) or issubclass(typ, tuple): if typ is list or typ is tuple:
if issubclass(typ, list): if typ is list:
if not object: if not object:
return "[]", True, False return "[]", True, False
format = "[%s]" format = "[%s]"
......
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