Commit fdda2001 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #19137: The pprint module now correctly formats empty set and frozenset

and instances of set and frozenset subclasses.
parent 3760d97f
......@@ -185,25 +185,18 @@ class PrettyPrinter:
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):
elif issubclass(typ, tuple):
write('(')
endchar = ')'
else:
if not length:
write('frozenset()')
write(rep)
return
write('frozenset([')
write(typ.__name__)
write('([')
endchar = '])'
indent += len(typ.__name__) + 1
object = _sorted(object)
indent += 10
else:
write('(')
endchar = ')'
if self._indent_per_level > 1 and sepLines:
write((self._indent_per_level - 1) * ' ')
if length:
......
This diff is collapsed.
......@@ -32,6 +32,9 @@ Core and Builtins
Library
-------
- Issue #19137: The pprint module now correctly formats empty set and frozenset
and instances of set and frozenset subclasses.
- Issue #16040: CVE-2013-1752: nntplib: Limit maximum line lengths to 2048 to
prevent readline() calls from consuming too much memory. Patch by Jyrki
Pulliainen.
......
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