Skip to content

Commit de7c3bf

Browse files
authored
gh-149189: Revert "Modern defaults for pprint (#149190)" (#150249)
1 parent e020836 commit de7c3bf

14 files changed

Lines changed: 868 additions & 762 deletions

File tree

Doc/library/difflib.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -728,18 +728,16 @@ Finally, we compare the two:
728728

729729
>>> from pprint import pprint
730730
>>> pprint(result)
731-
[
732-
' 1. Beautiful is better than ugly.\n',
733-
'- 2. Explicit is better than implicit.\n',
734-
'- 3. Simple is better than complex.\n',
735-
'+ 3. Simple is better than complex.\n',
736-
'? ++\n',
737-
'- 4. Complex is better than complicated.\n',
738-
'? ^ ---- ^\n',
739-
'+ 4. Complicated is better than complex.\n',
740-
'? ++++ ^ ^\n',
741-
'+ 5. Flat is better than nested.\n',
742-
]
731+
[' 1. Beautiful is better than ugly.\n',
732+
'- 2. Explicit is better than implicit.\n',
733+
'- 3. Simple is better than complex.\n',
734+
'+ 3. Simple is better than complex.\n',
735+
'? ++\n',
736+
'- 4. Complex is better than complicated.\n',
737+
'? ^ ---- ^\n',
738+
'+ 4. Complicated is better than complex.\n',
739+
'? ++++ ^ ^\n',
740+
'+ 5. Flat is better than nested.\n']
743741

744742
As a single multi-line string it looks like this:
745743

Doc/library/pprint.rst

Lines changed: 239 additions & 157 deletions
Large diffs are not rendered by default.

Doc/library/ssl.rst

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,79 +2473,67 @@ Visual inspection shows that the certificate does identify the desired service
24732473
(that is, the HTTPS host ``www.python.org``)::
24742474

24752475
>>> pprint.pprint(cert)
2476-
{
2477-
'OCSP': ('http://ocsp.digicert.com',),
2478-
'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt',),
2479-
'crlDistributionPoints': (
2480-
'http://crl3.digicert.com/sha2-ev-server-g1.crl',
2481-
'http://crl4.digicert.com/sha2-ev-server-g1.crl',
2482-
),
2483-
'issuer': (
2484-
(('countryName', 'US'),),
2485-
(('organizationName', 'DigiCert Inc'),),
2486-
(('organizationalUnitName', 'www.digicert.com'),),
2487-
(('commonName', 'DigiCert SHA2 Extended Validation Server CA'),),
2488-
),
2489-
'notAfter': 'Sep 9 12:00:00 2016 GMT',
2490-
'notBefore': 'Sep 5 00:00:00 2014 GMT',
2491-
'serialNumber': '01BB6F00122B177F36CAB49CEA8B6B26',
2492-
'subject': (
2493-
(('businessCategory', 'Private Organization'),),
2494-
(('1.3.6.1.4.1.311.60.2.1.3', 'US'),),
2495-
(('1.3.6.1.4.1.311.60.2.1.2', 'Delaware'),),
2496-
(('serialNumber', '3359300'),),
2497-
(('streetAddress', '16 Allen Rd'),),
2498-
(('postalCode', '03894-4801'),),
2499-
(('countryName', 'US'),),
2500-
(('stateOrProvinceName', 'NH'),),
2501-
(('localityName', 'Wolfeboro'),),
2502-
(('organizationName', 'Python Software Foundation'),),
2503-
(('commonName', 'www.python.org'),),
2504-
),
2505-
'subjectAltName': (
2506-
('DNS', 'www.python.org'),
2507-
('DNS', 'python.org'),
2508-
('DNS', 'pypi.org'),
2509-
('DNS', 'docs.python.org'),
2510-
('DNS', 'testpypi.org'),
2511-
('DNS', 'bugs.python.org'),
2512-
('DNS', 'wiki.python.org'),
2513-
('DNS', 'hg.python.org'),
2514-
('DNS', 'mail.python.org'),
2515-
('DNS', 'packaging.python.org'),
2516-
('DNS', 'pythonhosted.org'),
2517-
('DNS', 'www.pythonhosted.org'),
2518-
('DNS', 'test.pythonhosted.org'),
2519-
('DNS', 'us.pycon.org'),
2520-
('DNS', 'id.python.org'),
2521-
),
2522-
'version': 3,
2523-
}
2476+
{'OCSP': ('http://ocsp.digicert.com',),
2477+
'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt',),
2478+
'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g1.crl',
2479+
'http://crl4.digicert.com/sha2-ev-server-g1.crl'),
2480+
'issuer': ((('countryName', 'US'),),
2481+
(('organizationName', 'DigiCert Inc'),),
2482+
(('organizationalUnitName', 'www.digicert.com'),),
2483+
(('commonName', 'DigiCert SHA2 Extended Validation Server CA'),)),
2484+
'notAfter': 'Sep 9 12:00:00 2016 GMT',
2485+
'notBefore': 'Sep 5 00:00:00 2014 GMT',
2486+
'serialNumber': '01BB6F00122B177F36CAB49CEA8B6B26',
2487+
'subject': ((('businessCategory', 'Private Organization'),),
2488+
(('1.3.6.1.4.1.311.60.2.1.3', 'US'),),
2489+
(('1.3.6.1.4.1.311.60.2.1.2', 'Delaware'),),
2490+
(('serialNumber', '3359300'),),
2491+
(('streetAddress', '16 Allen Rd'),),
2492+
(('postalCode', '03894-4801'),),
2493+
(('countryName', 'US'),),
2494+
(('stateOrProvinceName', 'NH'),),
2495+
(('localityName', 'Wolfeboro'),),
2496+
(('organizationName', 'Python Software Foundation'),),
2497+
(('commonName', 'www.python.org'),)),
2498+
'subjectAltName': (('DNS', 'www.python.org'),
2499+
('DNS', 'python.org'),
2500+
('DNS', 'pypi.org'),
2501+
('DNS', 'docs.python.org'),
2502+
('DNS', 'testpypi.org'),
2503+
('DNS', 'bugs.python.org'),
2504+
('DNS', 'wiki.python.org'),
2505+
('DNS', 'hg.python.org'),
2506+
('DNS', 'mail.python.org'),
2507+
('DNS', 'packaging.python.org'),
2508+
('DNS', 'pythonhosted.org'),
2509+
('DNS', 'www.pythonhosted.org'),
2510+
('DNS', 'test.pythonhosted.org'),
2511+
('DNS', 'us.pycon.org'),
2512+
('DNS', 'id.python.org')),
2513+
'version': 3}
25242514

25252515
Now the SSL channel is established and the certificate verified, you can
25262516
proceed to talk with the server::
25272517

25282518
>>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n")
25292519
>>> pprint.pprint(conn.recv(1024).split(b"\r\n"))
2530-
[
2531-
b'HTTP/1.1 200 OK',
2532-
b'Date: Sat, 18 Oct 2014 18:27:20 GMT',
2533-
b'Server: nginx',
2534-
b'Content-Type: text/html; charset=utf-8',
2535-
b'X-Frame-Options: SAMEORIGIN',
2536-
b'Content-Length: 45679',
2537-
b'Accept-Ranges: bytes',
2538-
b'Via: 1.1 varnish',
2539-
b'Age: 2188',
2540-
b'X-Served-By: cache-lcy1134-LCY',
2541-
b'X-Cache: HIT',
2542-
b'X-Cache-Hits: 11',
2543-
b'Vary: Cookie',
2544-
b'Strict-Transport-Security: max-age=63072000; includeSubDomains',
2545-
b'Connection: close',
2546-
b'',
2547-
b'',
2548-
]
2520+
[b'HTTP/1.1 200 OK',
2521+
b'Date: Sat, 18 Oct 2014 18:27:20 GMT',
2522+
b'Server: nginx',
2523+
b'Content-Type: text/html; charset=utf-8',
2524+
b'X-Frame-Options: SAMEORIGIN',
2525+
b'Content-Length: 45679',
2526+
b'Accept-Ranges: bytes',
2527+
b'Via: 1.1 varnish',
2528+
b'Age: 2188',
2529+
b'X-Served-By: cache-lcy1134-LCY',
2530+
b'X-Cache: HIT',
2531+
b'X-Cache-Hits: 11',
2532+
b'Vary: Cookie',
2533+
b'Strict-Transport-Security: max-age=63072000; includeSubDomains',
2534+
b'Connection: close',
2535+
b'',
2536+
b'']
25492537

25502538
See the discussion of :ref:`ssl-security` below.
25512539

Doc/library/unittest.mock.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,12 +2347,10 @@ chained call:
23472347
<MagicMock name='mock().method().other()()' id='...'>
23482348
>>> kall = call(1).method(arg='foo').other('bar')(2.0)
23492349
>>> kall.call_list()
2350-
[
2351-
call(1),
2352-
call().method(arg='foo'),
2353-
call().method().other('bar'),
2354-
call().method().other()(2.0),
2355-
]
2350+
[call(1),
2351+
call().method(arg='foo'),
2352+
call().method().other('bar'),
2353+
call().method().other()(2.0)]
23562354
>>> m.mock_calls == kall.call_list()
23572355
True
23582356

Doc/tutorial/stdlib2.rst

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,11 @@ and indentation to more clearly reveal data structure::
3030
... 'yellow'], 'blue']]]
3131
...
3232
>>> pprint.pprint(t, width=30)
33-
[
34-
[
35-
[
36-
['black', 'cyan'],
37-
'white',
38-
['green', 'red'],
39-
],
40-
[
41-
[
42-
'magenta',
43-
'yellow',
44-
],
45-
'blue',
46-
],
47-
],
48-
]
33+
[[[['black', 'cyan'],
34+
'white',
35+
['green', 'red']],
36+
[['magenta', 'yellow'],
37+
'blue']]]
4938

5039
The :mod:`textwrap` module formats paragraphs of text to fit a given screen
5140
width::

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,11 +1343,12 @@ pickletools
13431343
pprint
13441344
------
13451345

1346-
* :mod:`pprint` now uses modern defaults: ``indent=4, width=88``,
1347-
and the default ``compact=False`` output is now formatted similar to
1348-
pretty-printed :func:`json.dumps`.
1346+
* Add an *expand* keyword argument for :func:`pprint.pprint`,
1347+
:func:`pprint.pformat`, :func:`pprint.pp`. If true, the output will be
1348+
formatted similar to pretty-printed :func:`json.dumps` when
1349+
*indent* is supplied.
13491350
(Contributed by Stefan Todoran, Semyon Moroz and Hugo van Kemenade in
1350-
:gh:`112632` and :gh:`149189`.)
1351+
:gh:`112632`.)
13511352

13521353
* Add t-string support to :mod:`pprint`.
13531354
(Contributed by Loïc Simon and Hugo van Kemenade in :gh:`134551`.)

Lib/difflib.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -559,17 +559,15 @@ def get_grouped_opcodes(self, n=3):
559559
>>> b[23:28] = [] # Make a deletion
560560
>>> b[30] += 'y' # Make another replacement
561561
>>> pprint(list(SequenceMatcher(None,a,b).get_grouped_opcodes()))
562-
[
563-
[('equal', 5, 8, 5, 8), ('insert', 8, 8, 8, 9), ('equal', 8, 11, 9, 12)],
564-
[
565-
('equal', 16, 19, 17, 20),
566-
('replace', 19, 20, 20, 21),
567-
('equal', 20, 22, 21, 23),
568-
('delete', 22, 27, 23, 23),
569-
('equal', 27, 30, 23, 26),
570-
],
571-
[('equal', 31, 34, 27, 30), ('replace', 34, 35, 30, 31), ('equal', 35, 38, 31, 34)],
572-
]
562+
[[('equal', 5, 8, 5, 8), ('insert', 8, 8, 8, 9), ('equal', 8, 11, 9, 12)],
563+
[('equal', 16, 19, 17, 20),
564+
('replace', 19, 20, 20, 21),
565+
('equal', 20, 22, 21, 23),
566+
('delete', 22, 27, 23, 23),
567+
('equal', 27, 30, 23, 26)],
568+
[('equal', 31, 34, 27, 30),
569+
('replace', 34, 35, 30, 31),
570+
('equal', 35, 38, 31, 34)]]
573571
"""
574572

575573
codes = self.get_opcodes()
@@ -786,18 +784,16 @@ class Differ:
786784
787785
>>> from pprint import pprint as _pprint
788786
>>> _pprint(result)
789-
[
790-
' 1. Beautiful is better than ugly.\n',
791-
'- 2. Explicit is better than implicit.\n',
792-
'- 3. Simple is better than complex.\n',
793-
'+ 3. Simple is better than complex.\n',
794-
'? ++\n',
795-
'- 4. Complex is better than complicated.\n',
796-
'? ^ ---- ^\n',
797-
'+ 4. Complicated is better than complex.\n',
798-
'? ++++ ^ ^\n',
799-
'+ 5. Flat is better than nested.\n',
800-
]
787+
[' 1. Beautiful is better than ugly.\n',
788+
'- 2. Explicit is better than implicit.\n',
789+
'- 3. Simple is better than complex.\n',
790+
'+ 3. Simple is better than complex.\n',
791+
'? ++\n',
792+
'- 4. Complex is better than complicated.\n',
793+
'? ^ ---- ^\n',
794+
'+ 4. Complicated is better than complex.\n',
795+
'? ++++ ^ ^\n',
796+
'+ 5. Flat is better than nested.\n']
801797
802798
As a single multi-line string it looks like this:
803799

0 commit comments

Comments
 (0)