I'd like to do the following:
- shell out to another executable from Python, using
subprocess.check_call - catch the stderr of the child process, if there is any
- add the stderr output to the CalledProcessError exception output from the parent process.
In theory this is simple. The check_call function signature contains a kwarg for stderr:
subprocess.check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False) However, immediately below that the documentation contains the following warning:
Note: Do not use
stdout=PIPEorstderr=PIPEwith this function. As the pipes are not being read in the current process, the child process may block if it generates enough output to a pipe to fill up the OS pipe buffer.
The problem is that pretty much every example I can find for getting stderr from the child process mentions using subprocess.PIPE to capture that output.
How can you capture stderr from the child process without using subprocess.PIPE?