STINNER Victor <vstin...@python.org> added the comment:

I updated my PR 23790 to add many usage of the new parameter, to see which kind 
of code would benefit of it.

--

Use case: Get the output of a command, don't fail if the command doesn't exist. 
Example: get "gcc --version" output.

It's common to redirect stderr to /dev/null.

The advantage of having a parameter is the ability to continue using regular 
subprocess methods without having to bother with the "command not found" case:

   proc.communicate()
   proc.stdout.read()
   if proc.returncode: ...
   ...

--

Tools/scripts/patchcheck.py calls subprocess.check_output() and uses "except 
subprocess.CalledProcessError:" to ignore any command error. But it doesn't 
catch "OSError" if the command doesn't exist (ex: "git" in this case).

*Maybe* exec_raise=False should even be the default behavior for functions like 
check_output()? But changing the default behavior is always a challenge for the 
backward compatibility :-(

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42648>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to