[New-bugs-announce] [issue22274] subprocess.Popen(stderr=STDOUT) fails to redirect subprocess stderr to stdout

Akira Li report at bugs.python.org
Mon Aug 25 23:46:02 CEST 2014


New submission from Akira Li:

The following command should not produce any output but it does:

  $ ./python >/dev/null -c 'import subprocess as S, sys; S.call([sys.executable, "-c", "import sys; print(42, file=sys.stderr)"], stderr=S.STDOUT)'

Its stdout is redirected to /dev/null. It starts a subprocess with its
stderr redirected to stdout. See "Redirect subprocess stderr to
stdout" [1] on Stackoverflow.

[1] http://stackoverflow.com/questions/11495783/redirect-subprocess-stderr-to-stdout

I've uploaded a patch that fixes the issue on POSIX.

Please, run the provided test (in the patch), to see whether the code
should be fixed on Windows too (it might work as is there).

No documentation changes are required.

Please, review.

----------
components: Library (Lib)
files: subprocess-stderr_redirect_with_no_stdout_redirect.diff
keywords: patch
messages: 225898
nosy: akira
priority: normal
severity: normal
status: open
title: subprocess.Popen(stderr=STDOUT) fails to redirect subprocess stderr to stdout
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file36472/subprocess-stderr_redirect_with_no_stdout_redirect.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22274>
_______________________________________


More information about the New-bugs-announce mailing list