summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-06-07 20:17:11 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-06-07 20:17:11 (GMT)
commite57000338f81ad09d5aa1d846ac2f8a39850b5e3 (patch)
treede90dd9a6cfb4bff5e41caf2e1c3e95998b732c4 /Lib/pprint.py
parent502ba4630358423dc3da4da0f3f938d3cb56281f (diff)
downloadcpython-e57000338f81ad09d5aa1d846ac2f8a39850b5e3.zip
cpython-e57000338f81ad09d5aa1d846ac2f8a39850b5e3.tar.gz
cpython-e57000338f81ad09d5aa1d846ac2f8a39850b5e3.tar.bz2
Patch #750542: Use issubclass instead of type identity.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 16d8eae..b8c0e88 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -130,7 +130,7 @@ class PrettyPrinter:
write = stream.write
if sepLines:
- if typ is dict:
+ if issubclass(typ, dict):
write('{')
if self._indent_per_level > 1:
write((self._indent_per_level - 1) * ' ')
@@ -157,8 +157,8 @@ class PrettyPrinter:
write('}')
return
- if typ is list or typ is tuple:
- if typ is list:
+ if issubclass(typ, list) or issubclass(typ, tuple):
+ if issubclass(typ, list):
write('[')
endchar = ']'
else:
@@ -179,7 +179,7 @@ class PrettyPrinter:
allowance + 1, context, level)
indent = indent - self._indent_per_level
del context[objid]
- if typ is tuple and length == 1:
+ if issubclass(typ, tuple) and length == 1:
write(',')
write(endchar)
return
@@ -207,7 +207,7 @@ class PrettyPrinter:
def _safe_repr(object, context, maxlevels, level):
typ = _type(object)
- if typ is str:
+ if issubclass(typ, basestring):
if 'locale' not in _sys.modules:
return `object`, True, False
if "'" in object and '"' not in object:
@@ -226,7 +226,7 @@ def _safe_repr(object, context, maxlevels, level):
write(qget(char, `char`[1:-1]))
return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
- if typ is dict:
+ if issubclass(typ, dict):
if not object:
return "{}", True, False
objid = _id(object)
@@ -251,8 +251,8 @@ def _safe_repr(object, context, maxlevels, level):
del context[objid]
return "{%s}" % _commajoin(components), readable, recursive
- if typ is list or typ is tuple:
- if typ is list:
+ if issubclass(typ, list) or issubclass(typ, tuple):
+ if issubclass(typ, list):
if not object:
return "[]", True, False
format = "[%s]"