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.

classification
Title: Documentation for subprocess.STDOUT needs clarification
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: subprocess.Popen(stderr=STDOUT) fails to redirect subprocess stderr to stdout
View: 22274
Assigned To: Nosy List: max
Priority: normal Keywords:

Created on 2017-05-26 17:42 by max, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (1)
msg294560 - (view) Author: Max (max) * Date: 2017-05-26 17:42
The documentation states that subprocess.STDOUT is:

Special value that can be used as the stderr argument to Popen and indicates that standard error should go into the same handle as standard output.

However, when Popen is called with stdout=None, stderr=subprocess.STDOUT, stderr is not redirected to stdout and continues to be sent to stderr.

To reproduce the problem:

$ python >/dev/null -c 'import subprocess;\
                        subprocess.call(["ls", "/404"],stderr=subprocess.STDOUT)'

and observe the error message appearing on the console (assuming /404 directory does not exist).

This was reported on SO 5 years ago: https://stackoverflow.com/questions/11495783/redirect-subprocess-stderr-to-stdout.

The SO attributed this to a documentation issue, but arguably it should be considered a bug because there seems to be no reason to make subprocess.STDOUT unusable in this very common use case.
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74673
2017-05-26 18:33:14eryksunsetstatus: open -> closed
superseder: subprocess.Popen(stderr=STDOUT) fails to redirect subprocess stderr to stdout
resolution: duplicate
stage: resolved
2017-05-26 17:42:41maxcreate