This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Richard Neumann, berker.peksag, conqp, rhettinger, sayanchowdhury, serhiy.storchaka, vstinner
Date 2017-02-27.11:26:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488194815.71.0.520387896523.issue25452@psf.upfronthosting.co.za>
In-reply-to
Content
For all reasons alread given in the previous comment and my comment below, I reject the proposed change.


Serhiy> See also issue26748. Classes usually have True boolean value, but empty enum classes were False-y by accident. This was considered a bug.

Another example: issue #13936, "RFE: change bool(datetime.time(0, 0, 0)) to evaluate as True". datetime.time was changed in Python 3.5 to always be true, especially for the time 00:00:00. It's the opposite of the proposed change for CompletedProcess.


The problem is also that different users can expect a different answer from bool(CompletedProcess): non-zero return code, non-empty stdout, empty stderr, etc.

CompleteProcess is a complex object with many attributes, it's not as simple as a tuple or a string, where the truthness is obvious.


> Richard Neumann: "A useless use case is attached."

"if subprocess.run(...):"

Sorry, I'm not convinced that the need of breaking the backward compatibility for this "useless use case". It's trivial to split it in two lines:

"cmd = subprocess.run(...); if cmd.returncode: (...)"

By the way, it became common that I write such code, and in this case, I need the returncode value in the if block:

"cmd = subprocess.run(...); if cmd.returncode: sys.exit(cmd.returncode)".

So I need the CompletedProcess object anyway.
History
Date User Action Args
2017-02-27 11:26:55vstinnersetrecipients: + vstinner, rhettinger, berker.peksag, serhiy.storchaka, sayanchowdhury, conqp, Richard Neumann
2017-02-27 11:26:55vstinnersetmessageid: <1488194815.71.0.520387896523.issue25452@psf.upfronthosting.co.za>
2017-02-27 11:26:55vstinnerlinkissue25452 messages
2017-02-27 11:26:55vstinnercreate