[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-27 Thread Ross Lagerwall
Changes by Ross Lagerwall : -- assignee: -> rosslagerwall resolution: -> fixed stage: -> committed/rejected status: open -> closed type: -> behavior ___ Python tracker ___ __

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-27 Thread Roundup Robot
Roundup Robot added the comment: New changeset 6119440bae30 by Ross Lagerwall in branch '2.7': Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is http://hg.python.org/cpython/rev/6119440bae30 -- ___ Python tracker

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-26 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1140b32747c9 by Ross Lagerwall in branch '3.2': Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is http://hg.python.org/cpython/rev/1140b32747c9 New changeset 943d323cb4b8 by Ross Lagerwall in branch 'default': Issue #12607:

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-26 Thread STINNER Victor
STINNER Victor added the comment: i12607_v2.patch: the test fails if Python is compiled with pydebug. Add "err = support.strip_python_stderr(err)" before self.assertEqual(err, b"err") in test_subprocess.py to fix the failure. -- versions: -Python 2.6, Python 3.1, Python 3.4

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-25 Thread Ross Lagerwall
Ross Lagerwall added the comment: communicate() requires setting stdin, stdout and stderr to subprocess.PIPE which defeats the purpose of the test: setting them to 0, 1 and 2 (in various orders) so that they need to be swapped... -- ___ Python trac

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-25 Thread STINNER Victor
STINNER Victor added the comment: save_fds should be moved outside the try block: +try: +# save a copy of the standard file descriptors +saved_fds = [os.dup(fd) for fd in range(3)] +... +finally: +for std, s

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-24 Thread Ross Lagerwall
Ross Lagerwall added the comment: Attached is a patch which tests all combinations and includes a testcase. -- nosy: +pitrou Added file: http://bugs.python.org/file22747/i12607_v2.patch ___ Python tracker

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread Christian Häggström
Christian Häggström added the comment: Thanks for the patch, I haven't tried it (I'm still on Python 2.7) but it looks very special-cased to my case. I can think about exotic cases like stdin = sys.stderr, stdout = sys.stdin, stderr = sys.stdout It can happen in reality if a daemon have close

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread Ross Lagerwall
Ross Lagerwall added the comment: It is indeed a problem. It seems like the problem comes about due to the "swapping" of fds. i.e. using stdout as stderr. The reverse appears to work due to the order in which the dup() calls are performed. Attached is a patch which fixes the issue. -

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread STINNER Victor
STINNER Victor added the comment: > stdout = open("/dev/null", "w"), stderr = sys.stdout Oh, I read subprocess.STDOUT instead of sys.stdout. -- ___ Python tracker ___ _

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread Christian Häggström
Christian Häggström added the comment: I expect that 'ls' print the error message on its stderr, which would be redirected to stdout of the test Python program. If I had been using stderr = subprocess.STDOUT, I can agree with you that both output streams would go to /dev/null. -- __

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread STINNER Victor
STINNER Victor added the comment: > stdout = open("/dev/null", "w"), stderr = sys.stdout You ask to write all outputs to /dev/null. Why do you expect anything on stdout? -- ___ Python tracker

[issue12607] subprocess(stdout=..., stderr=sys.stdout) breaks stderr for child

2011-07-22 Thread Christian Häggström
New submission from Christian Häggström : I hit a variant of issue #12251, namely when you redirect both stdout and stderr of a child process and one of them uses a low fd. Testcase: import subprocess, sys subprocess.call(["ls", "asda"], stderr = sys.stdout, stdout = open("/dev/null", "w")) s