[issue45048] subprocess.run(capture_output=Bool) does the opposite of expected
Eryk Sun
report at bugs.python.org
Sun Aug 29 18:50:18 EDT 2021
Eryk Sun <eryksun at gmail.com> added the comment:
The documentation states that "[i]f capture_output is true, stdout and stderr will be captured". This implies a container of some kind. So look to what subprocess.run() returns: "[w]ait for command to complete, then return a CompletedProcess instance". The `stdout` attribute of a CompletedProcess is the "[c]aptured stdout from the child process".
For example:
>>> p = subprocess.run("dir", shell=True, capture_output=True)
>>> p.stdout[:18]
b' Volume in drive C'
If the output is not captured, the child process inherits the standard output/error files of the parent process, which is typically a console or terminal.
FYI, the `dir` command is internal to the CMD shell in Windows, so it only works with shell=True. There is no "dir.exe" executable that can be executed with shell=False.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45048>
_______________________________________
More information about the Python-bugs-list
mailing list