Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 85918:fcd889046ee1 2.7
Issue #19137: The pprint module now correctly formats empty set and frozenset
and instances of set and frozenset subclasses.
| author | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| date | Wed, 02 Oct 2013 11:40:26 +0300 |
| parents | be3b4aa2ad28 |
| children |
line wrap: on
line diff
--- a/Lib/pprint.py Tue Oct 01 11:39:08 2013 -0400 +++ b/Lib/pprint.py Wed Oct 02 11:40:26 2013 +0300 @@ -185,25 +185,18 @@ if issubclass(typ, list): write('[') endchar = ']' - elif issubclass(typ, set): - if not length: - write('set()') - return - write('set([') - endchar = '])' - object = _sorted(object) - indent += 4 - elif issubclass(typ, frozenset): - if not length: - write('frozenset()') - return - write('frozenset([') - endchar = '])' - object = _sorted(object) - indent += 10 - else: + elif issubclass(typ, tuple): write('(') endchar = ')' + else: + if not length: + write(rep) + return + write(typ.__name__) + write('([') + endchar = '])' + indent += len(typ.__name__) + 1 + object = _sorted(object) if self._indent_per_level > 1 and sepLines: write((self._indent_per_level - 1) * ' ') if length:
