Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41546: make pprint (like print) not write to stdout when it is None #26810

Merged
merged 7 commits into from Jul 19, 2021

Conversation

@iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jun 20, 2021

https://bugs.python.org/issue41546

@iritkatriel iritkatriel changed the title bpo-41546: pprint (like print) does not write to stdout when it is None bpo-41546: make pprint (like print) not write to stdout when it is None Jun 20, 2021
@iritkatriel iritkatriel requested a review from zooba Jun 20, 2021
Lib/pprint.py Outdated Show resolved Hide resolved
@iritkatriel
Copy link
Member Author

@iritkatriel iritkatriel commented Jul 2, 2021

Any more comments before I merge?

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Please document the change.

with contextlib.redirect_stdout(None):
# smoke test - there is no output to check
pprint.pprint(simple)
Copy link
Member

@serhiy-storchaka serhiy-storchaka Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not it already tested in test_stdout_is_None?

Copy link
Member Author

@iritkatriel iritkatriel Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this is no longer needed, I'll remove. With my first (more complex) solution this covered more code paths.

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 3, 2021

Please document this behavior in the module documentation and add the versionchanged directive.

@iritkatriel
Copy link
Member Author

@iritkatriel iritkatriel commented Jul 3, 2021

Please document this behavior in the module documentation and add the versionchanged directive.

Done.

Probably not part of this PR, but I don't think the doc needs to repeat this twice. Could we not refer from pprint()'s doc to PrettyPrinter.pprint()'s doc?

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 3, 2021

Why not in this PR?

@iritkatriel
Copy link
Member Author

@iritkatriel iritkatriel commented Jul 3, 2021

Why not in this PR?

Sure, if you don't mind mixing two celebrations.

@iritkatriel
Copy link
Member Author

@iritkatriel iritkatriel commented Jul 18, 2021

Why not in this PR?

Sure, if you don't mind mixing two celebrations.

@serhiy-storchaka I've made the doc change, let me know if it looks ok.

Doc/library/pprint.rst Outdated Show resolved Hide resolved
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Added the *sort_dicts* parameter.

.. versionchanged:: 3.10
Added the *underscore_numbers* parameter.
Copy link
Member

@merwok merwok Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove versionchanged notes? People need to know this.

Copy link
Member Author

@iritkatriel iritkatriel Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're removing the repetitions.

Copy link
Member

@merwok merwok Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these are not needless repetitions: they are separate notes on separate functions.

Copy link
Member Author

@iritkatriel iritkatriel Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed repetition not only of the version labels but also of the definitions they relate to, and we replaced them by a reference to where those definitions appear (once).

It is easier read the docs when they are not repetitive because then you know that A is the same as B, and you don't need to do the work to compare them just to find that out.

@iritkatriel iritkatriel merged commit aab1899 into python:main Jul 19, 2021
13 checks passed
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Jul 19, 2021

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot PPC64 Fedora 3.x has failed when building commit aab1899.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/237/builds/560) and take a look at the build logs.
  4. Check if the failure is related to this commit (aab1899) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/237/builds/560

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 26, done.�[K
remote: Counting objects:   3% (1/26)�[K
remote: Counting objects:   7% (2/26)�[K
remote: Counting objects:  11% (3/26)�[K
remote: Counting objects:  15% (4/26)�[K
remote: Counting objects:  19% (5/26)�[K
remote: Counting objects:  23% (6/26)�[K
remote: Counting objects:  26% (7/26)�[K
remote: Counting objects:  30% (8/26)�[K
remote: Counting objects:  34% (9/26)�[K
remote: Counting objects:  38% (10/26)�[K
remote: Counting objects:  42% (11/26)�[K
remote: Counting objects:  46% (12/26)�[K
remote: Counting objects:  50% (13/26)�[K
remote: Counting objects:  53% (14/26)�[K
remote: Counting objects:  57% (15/26)�[K
remote: Counting objects:  61% (16/26)�[K
remote: Counting objects:  65% (17/26)�[K
remote: Counting objects:  69% (18/26)�[K
remote: Counting objects:  73% (19/26)�[K
remote: Counting objects:  76% (20/26)�[K
remote: Counting objects:  80% (21/26)�[K
remote: Counting objects:  84% (22/26)�[K
remote: Counting objects:  88% (23/26)�[K
remote: Counting objects:  92% (24/26)�[K
remote: Counting objects:  96% (25/26)�[K
remote: Counting objects: 100% (26/26)�[K
remote: Counting objects: 100% (26/26), done.�[K
remote: Compressing objects:   7% (1/14)�[K
remote: Compressing objects:  14% (2/14)�[K
remote: Compressing objects:  21% (3/14)�[K
remote: Compressing objects:  28% (4/14)�[K
remote: Compressing objects:  35% (5/14)�[K
remote: Compressing objects:  42% (6/14)�[K
remote: Compressing objects:  50% (7/14)�[K
remote: Compressing objects:  57% (8/14)�[K
remote: Compressing objects:  64% (9/14)�[K
remote: Compressing objects:  71% (10/14)�[K
remote: Compressing objects:  78% (11/14)�[K
remote: Compressing objects:  85% (12/14)�[K
remote: Compressing objects:  92% (13/14)�[K
remote: Compressing objects: 100% (14/14)�[K
remote: Compressing objects: 100% (14/14), done.�[K
remote: Total 14 (delta 12), reused 1 (delta 0), pack-reused 0�[K
From https://github.com/python/cpython
 * branch            main       -> FETCH_HEAD
Note: checking out 'aab1899c9d79083c1ff31d974ed8b562d3ca3b5d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at aab1899... [bpo-41546](https://bugs.python.org/issue41546): make pprint (like print) not write to stdout when it is None (GH-26810)
Switched to and reset branch 'main'

./configure: line 10530: PKG_PROG_PKG_CONFIG: command not found

/tmp/ccKQYNxd.s: Assembler messages:
/tmp/ccKQYNxd.s: Fatal error: can't close Parser/parser.o: No space left on device
make: *** [Parser/parser.o] Error 1

find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
find: ‘build’: No such file or directory
make: [clean-retain-profile] Error 1 (ignored)

@iritkatriel
Copy link
Member Author

@iritkatriel iritkatriel commented Jul 19, 2021

The build failure seems unrelated to this change:

/tmp/ccKQYNxd.s: Assembler messages:
/tmp/ccKQYNxd.s: Fatal error: can't close Parser/parser.o: No space left on device
make: *** [Parser/parser.o] Error 1

shihai1991 added a commit to shihai1991/cpython that referenced this issue Jul 20, 2021
* origin/main: (1146 commits)
  bpo-42064: Finalise establishing sqlite3 global state (pythonGH-27155)
  bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (pythonGH-27249)
  correct spelling (pythonGH-27076)
  bpo-44524: Add missed __name__ and __qualname__ to typing module objects (python#27237)
  bpo-27513: email.utils.getaddresses() now handles Header objects (python#13797)
  Clean up comma usage in Doc/library/functions.rst (python#27083)
  bpo-42238: Fix small rst issue in NEWS.d/. (python#27238)
  bpo-41972: Tweak fastsearch.h string search algorithms (pythonGH-27091)
  bpo-44340: Add support for building with clang full/thin lto (pythonGH-27231)
  bpo-44661: Update property_descr_set to use vectorcall if possible. (pythonGH-27206)
  bpo-44645: Check for interrupts on any potentially backwards edge (pythonGH-27216)
  bpo-41546: make pprint (like print) not write to stdout when it is None (pythonGH-26810)
  bpo-44554: refactor pdb targets (and internal tweaks) (pythonGH-26992)
  bpo-43086: Add handling for out-of-spec data in a2b_base64 (pythonGH-24402)
  bpo-44561: Update hyperlinks in Doc/distributing/index.rst (python#27032)
  bpo-42355: symtable.get_namespace() now checks whether there are multiple or any namespaces found (pythonGH-23278)
  bpo-44654: Do not export the union type related symbols (pythonGH-27223)
  bpo-44633: Fix parameter substitution of the union type with wrong types. (pythonGH-27218)
  bpo-44654: Refactor and clean up the union type implementation (pythonGH-27196)
  bpo-20291: Fix MSVC warnings in getargs.c (pythonGH-27211)
  ...
shihai1991 added a commit to shihai1991/cpython that referenced this issue Jul 20, 2021
* origin/main: (1146 commits)
  bpo-42064: Finalise establishing sqlite3 global state (pythonGH-27155)
  bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (pythonGH-27249)
  correct spelling (pythonGH-27076)
  bpo-44524: Add missed __name__ and __qualname__ to typing module objects (python#27237)
  bpo-27513: email.utils.getaddresses() now handles Header objects (python#13797)
  Clean up comma usage in Doc/library/functions.rst (python#27083)
  bpo-42238: Fix small rst issue in NEWS.d/. (python#27238)
  bpo-41972: Tweak fastsearch.h string search algorithms (pythonGH-27091)
  bpo-44340: Add support for building with clang full/thin lto (pythonGH-27231)
  bpo-44661: Update property_descr_set to use vectorcall if possible. (pythonGH-27206)
  bpo-44645: Check for interrupts on any potentially backwards edge (pythonGH-27216)
  bpo-41546: make pprint (like print) not write to stdout when it is None (pythonGH-26810)
  bpo-44554: refactor pdb targets (and internal tweaks) (pythonGH-26992)
  bpo-43086: Add handling for out-of-spec data in a2b_base64 (pythonGH-24402)
  bpo-44561: Update hyperlinks in Doc/distributing/index.rst (python#27032)
  bpo-42355: symtable.get_namespace() now checks whether there are multiple or any namespaces found (pythonGH-23278)
  bpo-44654: Do not export the union type related symbols (pythonGH-27223)
  bpo-44633: Fix parameter substitution of the union type with wrong types. (pythonGH-27218)
  bpo-44654: Refactor and clean up the union type implementation (pythonGH-27196)
  bpo-20291: Fix MSVC warnings in getargs.c (pythonGH-27211)
  ...
shihai1991 added a commit to shihai1991/cpython that referenced this issue Jul 20, 2021
* origin/main: (1146 commits)
  bpo-42064: Finalise establishing sqlite3 global state (pythonGH-27155)
  bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (pythonGH-27249)
  correct spelling (pythonGH-27076)
  bpo-44524: Add missed __name__ and __qualname__ to typing module objects (python#27237)
  bpo-27513: email.utils.getaddresses() now handles Header objects (python#13797)
  Clean up comma usage in Doc/library/functions.rst (python#27083)
  bpo-42238: Fix small rst issue in NEWS.d/. (python#27238)
  bpo-41972: Tweak fastsearch.h string search algorithms (pythonGH-27091)
  bpo-44340: Add support for building with clang full/thin lto (pythonGH-27231)
  bpo-44661: Update property_descr_set to use vectorcall if possible. (pythonGH-27206)
  bpo-44645: Check for interrupts on any potentially backwards edge (pythonGH-27216)
  bpo-41546: make pprint (like print) not write to stdout when it is None (pythonGH-26810)
  bpo-44554: refactor pdb targets (and internal tweaks) (pythonGH-26992)
  bpo-43086: Add handling for out-of-spec data in a2b_base64 (pythonGH-24402)
  bpo-44561: Update hyperlinks in Doc/distributing/index.rst (python#27032)
  bpo-42355: symtable.get_namespace() now checks whether there are multiple or any namespaces found (pythonGH-23278)
  bpo-44654: Do not export the union type related symbols (pythonGH-27223)
  bpo-44633: Fix parameter substitution of the union type with wrong types. (pythonGH-27218)
  bpo-44654: Refactor and clean up the union type implementation (pythonGH-27196)
  bpo-20291: Fix MSVC warnings in getargs.c (pythonGH-27211)
  ...
shihai1991 added a commit to shihai1991/cpython that referenced this issue Jul 20, 2021
* origin/main: (1146 commits)
  bpo-42064: Finalise establishing sqlite3 global state (pythonGH-27155)
  bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (pythonGH-27249)
  correct spelling (pythonGH-27076)
  bpo-44524: Add missed __name__ and __qualname__ to typing module objects (python#27237)
  bpo-27513: email.utils.getaddresses() now handles Header objects (python#13797)
  Clean up comma usage in Doc/library/functions.rst (python#27083)
  bpo-42238: Fix small rst issue in NEWS.d/. (python#27238)
  bpo-41972: Tweak fastsearch.h string search algorithms (pythonGH-27091)
  bpo-44340: Add support for building with clang full/thin lto (pythonGH-27231)
  bpo-44661: Update property_descr_set to use vectorcall if possible. (pythonGH-27206)
  bpo-44645: Check for interrupts on any potentially backwards edge (pythonGH-27216)
  bpo-41546: make pprint (like print) not write to stdout when it is None (pythonGH-26810)
  bpo-44554: refactor pdb targets (and internal tweaks) (pythonGH-26992)
  bpo-43086: Add handling for out-of-spec data in a2b_base64 (pythonGH-24402)
  bpo-44561: Update hyperlinks in Doc/distributing/index.rst (python#27032)
  bpo-42355: symtable.get_namespace() now checks whether there are multiple or any namespaces found (pythonGH-23278)
  bpo-44654: Do not export the union type related symbols (pythonGH-27223)
  bpo-44633: Fix parameter substitution of the union type with wrong types. (pythonGH-27218)
  bpo-44654: Refactor and clean up the union type implementation (pythonGH-27196)
  bpo-20291: Fix MSVC warnings in getargs.c (pythonGH-27211)
  ...
@iritkatriel iritkatriel deleted the bpo-41546 branch Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants