summaryrefslogtreecommitdiffstats
path: root/pym/portage
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-08-22 12:46:04 -0700
committerZac Medico <zmedico@gentoo.org>2012-08-22 12:46:04 -0700
commit77cb4022c981c3c6ba96533a55058a643f60d334 (patch)
treeeb387d63ef2dc7f354fef7cb5f4867f4ddcbcb2f /pym/portage
parent7a55f93d76bab41f025b77fc4e356d6a5b4b9385 (diff)
downloadportage-77cb4022c981c3c6ba96533a55058a643f60d334.tar.gz
portage-77cb4022c981c3c6ba96533a55058a643f60d334.tar.bz2
portage-77cb4022c981c3c6ba96533a55058a643f60d334.zip
Use sys.__std*.fileno() in case of overrides.
This fixes AttributeError exceptions for API consumers that override sys.std* streams pseudo-file objects.
Diffstat (limited to 'pym/portage')
-rw-r--r--pym/portage/getbinpkg.py8
-rw-r--r--pym/portage/package/ebuild/doebuild.py18
-rw-r--r--pym/portage/package/ebuild/fetch.py6
-rw-r--r--pym/portage/process.py6
4 files changed, 20 insertions, 18 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 212f78889..34a5e0efe 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -466,10 +466,12 @@ def file_get(baseurl,dest,conn=None,fcmd=None,filename=None):
myfetch = portage.util.shlex_split(fcmd)
myfetch = [varexpand(x, mydict=variables) for x in myfetch]
fd_pipes= {
- 0:sys.stdin.fileno(),
- 1:sys.stdout.fileno(),
- 2:sys.stdout.fileno()
+ 0:sys.__stdin__.fileno(),
+ 1:sys.__stdout__.fileno(),
+ 2:sys.__stdout__.fileno()
}
+ sys.__stdout__.flush()
+ sys.__stderr__.flush()
retval = spawn(myfetch, env=os.environ.copy(), fd_pipes=fd_pipes)
if retval != os.EX_OK:
sys.stderr.write(_("Fetcher exited with a failure condition.\n"))
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 395e0eeec..ef51da1b4 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -690,9 +690,9 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
mysettings["dbkey"] = ""
pr, pw = os.pipe()
fd_pipes = {
- 0:sys.stdin.fileno(),
- 1:sys.stdout.fileno(),
- 2:sys.stderr.fileno(),
+ 0:sys.__stdin__.fileno(),
+ 1:sys.__stdout__.fileno(),
+ 2:sys.__stderr__.fileno(),
9:pw}
mypids = _spawn_phase(mydo, mysettings, returnpid=True,
fd_pipes=fd_pipes)
@@ -1367,18 +1367,18 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
fd_pipes = keywords.get("fd_pipes")
if fd_pipes is None:
fd_pipes = {
- 0:sys.stdin.fileno(),
- 1:sys.stdout.fileno(),
- 2:sys.stderr.fileno(),
+ 0:sys.__stdin__.fileno(),
+ 1:sys.__stdout__.fileno(),
+ 2:sys.__stderr__.fileno(),
}
# In some cases the above print statements don't flush stdout, so
# it needs to be flushed before allowing a child process to use it
# so that output always shows in the correct order.
- stdout_filenos = (sys.stdout.fileno(), sys.stderr.fileno())
+ stdout_filenos = (sys.__stdout__.fileno(), sys.__stderr__.fileno())
for fd in fd_pipes.values():
if fd in stdout_filenos:
- sys.stdout.flush()
- sys.stderr.flush()
+ sys.__stdout__.flush()
+ sys.__stderr__.flush()
break
features = mysettings.features
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
index 576a91239..260bf10bb 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -64,9 +64,9 @@ def _spawn_fetch(settings, args, **kwargs):
if "fd_pipes" not in kwargs:
kwargs["fd_pipes"] = {
- 0 : sys.stdin.fileno(),
- 1 : sys.stdout.fileno(),
- 2 : sys.stdout.fileno(),
+ 0 : sys.__stdin__.fileno(),
+ 1 : sys.__stdout__.fileno(),
+ 2 : sys.__stdout__.fileno(),
}
if "userfetch" in settings.features and \
diff --git a/pym/portage/process.py b/pym/portage/process.py
index f3cec8815..32e60ac50 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -226,9 +226,9 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
# default to propagating our stdin, stdout and stderr.
if fd_pipes is None:
fd_pipes = {
- 0:sys.stdin.fileno(),
- 1:sys.stdout.fileno(),
- 2:sys.stderr.fileno(),
+ 0:sys.__stdin__.fileno(),
+ 1:sys.__stdout__.fileno(),
+ 2:sys.__stderr__.fileno(),
}
# mypids will hold the pids of all processes created.