summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-02 08:43:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-02 08:43:30 (GMT)
commit092bd388ced26650cf0a5a4838a87f7ca8a9ea97 (patch)
tree8e01d43c091b4e0469c837434a465e03d91a22b8 /Lib/pprint.py
parent75f65e368e04c6242c103d3139571b8aaad8b4be (diff)
parent51844384f4b225d214e122edd8af65c75e50a150 (diff)
downloadcpython-092bd388ced26650cf0a5a4838a87f7ca8a9ea97.zip
cpython-092bd388ced26650cf0a5a4838a87f7ca8a9ea97.tar.gz
cpython-092bd388ced26650cf0a5a4838a87f7ca8a9ea97.tar.bz2
Issue #19137: The pprint module now correctly formats instances of set and
frozenset subclasses.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 1f98f5c..f4bc59b 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -203,24 +203,22 @@ class PrettyPrinter:
if issubclass(typ, list):
write('[')
endchar = ']'
- elif issubclass(typ, set):
- if not length:
- write('set()')
- return
- write('{')
- endchar = '}'
- object = sorted(object, key=_safe_key)
- elif issubclass(typ, frozenset):
+ elif issubclass(typ, tuple):
+ write('(')
+ endchar = ')'
+ else:
if not length:
- write('frozenset()')
+ write(rep)
return
- write('frozenset({')
- endchar = '})'
+ if typ is set:
+ write('{')
+ endchar = '}'
+ else:
+ write(typ.__name__)
+ write('({')
+ endchar = '})'
+ indent += len(typ.__name__) + 1
object = sorted(object, key=_safe_key)
- indent += 10
- else:
- write('(')
- endchar = ')'
if self._indent_per_level > 1:
write((self._indent_per_level - 1) * ' ')
if length: