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.

Author socketpair
Recipients socketpair
Date 2011-06-03.09:47:07
SpamBayes Score 6.113321e-07
Marked as misclassified No
Message-id <1307094428.89.0.00113133109323.issue12251@psf.upfronthosting.co.za>
In-reply-to
Content
How to test:
----------------
#! /usr/bin/python
import subprocess, sys

# will print err to sys.stderr
subprocess.call(['rmdir', '/no_such_dir'])

# will NOT print err to sys.stderr
subprocess.call(['rmdir', '/no_such_dir'], stdout=sys.stderr)
----------------

According to strace, in child process:
-----------------
dup2(2, 1) // that's what I expect, okay
close(2) // that's I was not expect, so bug here
execve(...)
-----------------

Bug is in subprocess.py:
(search for "dup2" in file)
I do not known how to fix correctly. Logick in this module is brain damaged in some places.

-----------------------------
# Dup fds for child
if p2cread is not None:
    os.dup2(p2cread, 0)
if c2pwrite is not None:
    os.dup2(c2pwrite, 1)
if errwrite is not None:
    os.dup2(errwrite, 2)

# Close pipe fds.  Make sure we don't close the same
# fd more than once, or standard fds.
if p2cread is not None and p2cread not in (0,):
    os.close(p2cread)
if c2pwrite is not None and c2pwrite not in (p2cread, 1):
    os.close(c2pwrite)
if errwrite is not None and errwrite not in (p2cread, c2pwrite, 2):
    os.close(errwrite)
-------------------------
History
Date User Action Args
2011-06-03 09:47:09socketpairsetrecipients: + socketpair
2011-06-03 09:47:08socketpairsetmessageid: <1307094428.89.0.00113133109323.issue12251@psf.upfronthosting.co.za>
2011-06-03 09:47:08socketpairlinkissue12251 messages
2011-06-03 09:47:07socketpaircreate