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-40497: Fix handling of check in subprocess.check_output() #19897

Merged
merged 9 commits into from Sep 20, 2021

Conversation

@remilapeyre
Copy link
Contributor

@remilapeyre remilapeyre commented May 4, 2020

https://bugs.python.org/issue40497

Copy link
Contributor

@taleinat taleinat left a comment

LGTM

@taleinat
Copy link
Contributor

@taleinat taleinat commented Oct 18, 2020

I'm only wondering if we should have a deprecation period for disallowing check=True. @gpshead, thoughts on this?

@@ -162,6 +162,14 @@ def test_check_output(self):
[sys.executable, "-c", "print('BDFL')"])
self.assertIn(b'BDFL', output)

with self.assertRaisesRegex(ValueError,
"stdout argument not allowed, it will be overridden"):
Copy link
Member

@gpshead gpshead Oct 18, 2020

Choose a reason for hiding this comment

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

when asserting raised exceptions, don't assert anything about the error message text unless that is critically important. here i would change these to either plain assertRaises(ValueError) or to a very permissive assertRaisesRegex(ValueError, ...) just looking for the word "stdout" in this one and "check" in the one below. The actual text of the error message does not matter and should be able to be tweaked without someone needing to update a change-detector test.

Lib/subprocess.py Show resolved Hide resolved
@gpshead gpshead self-assigned this Oct 18, 2020
Lib/subprocess.py Show resolved Hide resolved
@gpshead
Copy link
Member

@gpshead gpshead commented Oct 18, 2020

regarding deprecation, no need. the argument, if specified at all, is already a TypeError. This change just makes it be the correct ValueError with a friendlier error message.

@@ -0,0 +1,3 @@
Disallow passing a *check* parameter to :meth:`subprocess.check_output`,
Copy link
Contributor

@akulakov akulakov Aug 27, 2021

Choose a reason for hiding this comment

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

I think this news entry makes it sound like behavior was changed, and will prompt users to review their codebases for use of check parameter.

It may be better to say that the exception raised was changed from TypeError to ValueError and that error message was changed to be easier to understand. It may be good to mention that it applies to stdout arg as well.

Copy link
Contributor

@ambv ambv Sep 17, 2021

Choose a reason for hiding this comment

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

Agreed, Andrei.

@ambv ambv merged commit 4d2957c into python:main Sep 20, 2021
11 of 12 checks passed
nsait-linaro added a commit to nsait-linaro/cpython that referenced this issue Sep 21, 2021
…GH-19897)

Co-authored-by: Tal Einat <taleinat@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants