[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Thanks for the suggestion though ThatXliner.  It is good for us to keep these 
things in mind for future API designs.  That __bool__ exists and could be 
meaningful in some contexts is often overlooked.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

My concern with this as an API change is if anyone is returning or passing a 
CompletedProcess instance around it may well be used in a context where None is 
a potential value.  Existing code in that situation would ordinarily be doing a 
bare `if cp:` test on it to check for None.

I don't ordinarily see code that passes a CompletedProcess instance around... 
but it seems like an annoying potentially breaking change to make for a very 
small added value.

`if cp.returncode:` is very explicit about its intent when read or written.  

`if cp:` is not, and could even be misread by someone unaware of the API to 
assume that cp is a number most likely the returncode itself and misunderstand 
that as "the returncode was non-zero" when it really means the opposite.

If we had done this on day one of the run() -> CompletedProcess API this 
would've been a fine choice.  But changing it now doesn't seem like a good idea 
to me.

--
versions:  -Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Here's a before and after example from my code.

==

class GraphvizResult(NamedTuple):
svg: str
err: str

def create_svg(dot: str) -> GraphvizResult:
'Convert a string in the "dot" format to an "svg" string using Graphviz'
cp = run(['dot', '-Tsvg'], input=dot, capture_output=True, text=True)
result = cp.stdout
if not cp.returncode:
i = result.index(' GraphvizResult:
'Convert a string in the "dot" format to an "svg" string using Graphviz'
cp = run(['dot', '-Tsvg'], input=dot, capture_output=True, text=True)
result = cp.stdout
if cp:
i = result.index('

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
assignee:  -> gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Greg, do you have an opinion here?

--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread ThatXliner


New submission from ThatXliner :

I propose making subprocess.CompletedProcess a truthy value if the returncode 
is 0. False, otherwise.

--
components: Library (Lib)
messages: 381871
nosy: ThatXliner
priority: normal
severity: normal
status: open
title: subprocess.CompletedProcess: Add boolean value
versions: Python 3.10, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42468] subprocess.CompletedProcess: Add boolean value

2020-11-25 Thread ThatXliner


Change by ThatXliner :


--
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com