cpython: 4d3066d4a5df (original) (raw)

Mercurial > cpython

changeset 93941:4d3066d4a5df

Issue #19104: pprint now produces evaluable output for wrapped strings. [#19104]

Serhiy Storchaka storchaka@gmail.com
date Sat, 20 Dec 2014 20:58:28 +0200
parents 7cb79c494abc(current diff)872f048f0403(diff)
children 75ede5bec8db
files Misc/NEWS
diffstat 3 files changed, 47 insertions(+), 36 deletions(-)[+] [-] Lib/pprint.py 58 Lib/test/test_pprint.py 23 Misc/NEWS 2

line wrap: on

line diff

--- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -235,35 +235,41 @@ class PrettyPrinter: return if issubclass(typ, str) and len(object) > 0 and r is str.repr:

--- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -536,9 +536,10 @@ frozenset2({0, # pprint tries to wrap strings intelligently fox = 'the quick brown fox jumped over a lazy dog' self.assertEqual(pprint.pformat(fox, width=20), """[](#l2.6) -'the quick brown ' -'fox jumped over ' -'a lazy dog'""") +('the quick '

{'a': 1, @@ -552,12 +553,12 @@ frozenset2({0, # - non-ASCII is allowed # - an apostrophe doesn't disrupt the pprint special = "Portons dix bons "whiskys"\nà l'avocat goujat\t qui fumait au zoo"

-'Portons dix bons ' -'"whiskys"\n' -"à l'avocat " -'goujat\t qui ' -'fumait au zoo'""")

+('Portons dix '

@@ -566,7 +567,9 @@ frozenset2({0, special *= 10 for width in range(3, 40): formatted = pprint.pformat(special, width=width)

def test_compact(self): o = ([list(range(i * i)) for i in range(5)] +

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -196,6 +196,8 @@ Core and Builtins Library ------- +- Issue #19104: pprint now produces evaluable output for wrapped strings. +