diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-02 08:40:49 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-02 08:40:49 (GMT) |
commit | 51844384f4b225d214e122edd8af65c75e50a150 (patch) | |
tree | 09f4e10baa384ff1f1671b75f923e530cdbc0f09 /Lib/pprint.py | |
parent | 224c87d60ca32b99a6a670545c5b09b2bdef0b41 (diff) | |
download | cpython-51844384f4b225d214e122edd8af65c75e50a150.zip cpython-51844384f4b225d214e122edd8af65c75e50a150.tar.gz cpython-51844384f4b225d214e122edd8af65c75e50a150.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.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py index ae96dde..22be0b4b 100644 --- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -205,24 +205,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: |