Kaydet (Commit) fdda2001 authored tarafından 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.
üst 3760d97f
...@@ -185,25 +185,18 @@ class PrettyPrinter: ...@@ -185,25 +185,18 @@ class PrettyPrinter:
if issubclass(typ, list): if issubclass(typ, list):
write('[') write('[')
endchar = ']' endchar = ']'
elif issubclass(typ, set): elif issubclass(typ, tuple):
if not length: write('(')
write('set()') endchar = ')'
return else:
write('set([')
endchar = '])'
object = _sorted(object)
indent += 4
elif issubclass(typ, frozenset):
if not length: if not length:
write('frozenset()') write(rep)
return return
write('frozenset([') write(typ.__name__)
write('([')
endchar = '])' endchar = '])'
indent += len(typ.__name__) + 1
object = _sorted(object) object = _sorted(object)
indent += 10
else:
write('(')
endchar = ')'
if self._indent_per_level > 1 and sepLines: if self._indent_per_level > 1 and sepLines:
write((self._indent_per_level - 1) * ' ') write((self._indent_per_level - 1) * ' ')
if length: if length:
......
This diff is collapsed.
...@@ -32,6 +32,9 @@ Core and Builtins ...@@ -32,6 +32,9 @@ Core and Builtins
Library 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 - Issue #16040: CVE-2013-1752: nntplib: Limit maximum line lengths to 2048 to
prevent readline() calls from consuming too much memory. Patch by Jyrki prevent readline() calls from consuming too much memory. Patch by Jyrki
Pulliainen. 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