* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/portage/, pym/_emerge/
@ 2012-08-22 19:46 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-08-22 19:46 UTC (permalink / raw
To: gentoo-commits
commit: 77cb4022c981c3c6ba96533a55058a643f60d334
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 22 19:46:04 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 22 19:46:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=77cb4022
Use sys.__std*.fileno() in case of overrides.
This fixes AttributeError exceptions for API consumers that override
sys.std* streams pseudo-file objects.
---
bin/dispatch-conf | 10 ++++++----
pym/_emerge/BinpkgFetcher.py | 10 +++++-----
pym/_emerge/EbuildMetadataPhase.py | 12 ++++++------
pym/_emerge/SpawnProcess.py | 16 ++++++++--------
pym/portage/getbinpkg.py | 8 +++++---
pym/portage/package/ebuild/doebuild.py | 18 +++++++++---------
pym/portage/package/ebuild/fetch.py | 6 +++---
pym/portage/process.py | 6 +++---
8 files changed, 45 insertions(+), 41 deletions(-)
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index 139a001..35979db 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -1,5 +1,5 @@
#!/usr/bin/python -O
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
@@ -463,10 +463,12 @@ if not shell or not os.access(shell, os.EX_OK):
def spawn_shell(cmd):
if shell:
+ sys.__stdout__.flush()
+ sys.__stderr__.flush()
spawn([shell, "-c", cmd], env=os.environ,
- fd_pipes = { 0 : sys.stdin.fileno(),
- 1 : sys.stdout.fileno(),
- 2 : sys.stderr.fileno()})
+ fd_pipes = { 0 : sys.__stdin__.fileno(),
+ 1 : sys.__stdout__.fileno(),
+ 2 : sys.__stderr__.fileno()})
else:
os.system(cmd)
diff --git a/pym/_emerge/BinpkgFetcher.py b/pym/_emerge/BinpkgFetcher.py
index f415e2e..1913b44 100644
--- a/pym/_emerge/BinpkgFetcher.py
+++ b/pym/_emerge/BinpkgFetcher.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.AsynchronousLock import AsynchronousLock
@@ -91,9 +91,9 @@ class BinpkgFetcher(SpawnProcess):
# Redirect all output to stdout since some fetchers like
# wget pollute stderr (if portage detects a problem then it
# can send it's own message to stderr).
- fd_pipes.setdefault(0, sys.stdin.fileno())
- fd_pipes.setdefault(1, sys.stdout.fileno())
- fd_pipes.setdefault(2, sys.stdout.fileno())
+ fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(1, sys.__stdout__.fileno())
+ fd_pipes.setdefault(2, sys.__stdout__.fileno())
self.args = fetch_args
self.env = fetch_env
@@ -104,7 +104,7 @@ class BinpkgFetcher(SpawnProcess):
def _pipe(self, fd_pipes):
"""When appropriate, use a pty so that fetcher progress bars,
like wget has, will work properly."""
- if self.background or not sys.stdout.isatty():
+ if self.background or not sys.__stdout__.isatty():
# When the output only goes to a log file,
# there's no point in creating a pty.
return os.pipe()
diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py
index c2d3747..d49c51f 100644
--- a/pym/_emerge/EbuildMetadataPhase.py
+++ b/pym/_emerge/EbuildMetadataPhase.py
@@ -74,15 +74,15 @@ class EbuildMetadataPhase(SubProcess):
null_input = open('/dev/null', 'rb')
fd_pipes.setdefault(0, null_input.fileno())
- fd_pipes.setdefault(1, sys.stdout.fileno())
- fd_pipes.setdefault(2, sys.stderr.fileno())
+ fd_pipes.setdefault(1, sys.__stdout__.fileno())
+ fd_pipes.setdefault(2, sys.__stderr__.fileno())
# flush any pending output
for fd in fd_pipes.values():
- if fd == sys.stdout.fileno():
- sys.stdout.flush()
- if fd == sys.stderr.fileno():
- sys.stderr.flush()
+ if fd == sys.__stdout__.fileno():
+ sys.__stdout__.flush()
+ if fd == sys.__stderr__.fileno():
+ sys.__stderr__.flush()
self._files = self._files_dict()
files = self._files
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index 9fbc964..dfcf088 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.SubProcess import SubProcess
@@ -62,16 +62,16 @@ class SpawnProcess(SubProcess):
null_input = os.open('/dev/null', os.O_RDWR)
fd_pipes[0] = null_input
- fd_pipes.setdefault(0, sys.stdin.fileno())
- fd_pipes.setdefault(1, sys.stdout.fileno())
- fd_pipes.setdefault(2, sys.stderr.fileno())
+ fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(1, sys.__stdout__.fileno())
+ fd_pipes.setdefault(2, sys.__stderr__.fileno())
# flush any pending output
for fd in fd_pipes.values():
- if fd == sys.stdout.fileno():
- sys.stdout.flush()
- if fd == sys.stderr.fileno():
- sys.stderr.flush()
+ if fd == sys.__stdout__.fileno():
+ sys.__stdout__.flush()
+ if fd == sys.__stderr__.fileno():
+ sys.__stderr__.flush()
if logfile is not None:
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 212f788..34a5e0e 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 395e0ee..ef51da1 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 576a912..260bf10 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 f3cec88..32e60ac 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.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/portage/, pym/_emerge/
@ 2012-12-15 22:04 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2012-12-15 22:04 UTC (permalink / raw
To: gentoo-commits
commit: 0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 15 22:04:28 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 15 22:04:28 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0db4c2a0
Handle closed sys.__stdin__, for multiprocessing
Buggy code in python's multiprocessing/process.py closes sys.stdin and
reassigns it to open(os.devnull), but fails to update the corresponding
__stdin__ reference. So, detect that case and handle it appropriately.
The buggy code is visible in http://hg.python.org/lookup/r73708.
---
bin/dispatch-conf | 2 +-
pym/_emerge/BinpkgFetcher.py | 2 +-
pym/_emerge/SpawnProcess.py | 2 +-
pym/portage/__init__.py | 11 +++++++++++
pym/portage/getbinpkg.py | 2 +-
pym/portage/package/ebuild/doebuild.py | 4 ++--
pym/portage/package/ebuild/fetch.py | 2 +-
pym/portage/process.py | 2 +-
8 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index e5f7680..479647e 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -462,7 +462,7 @@ def spawn_shell(cmd):
sys.__stdout__.flush()
sys.__stderr__.flush()
spawn([shell, "-c", cmd], env=os.environ,
- fd_pipes = { 0 : sys.__stdin__.fileno(),
+ fd_pipes = { 0 : portage._get_stdin().fileno(),
1 : sys.__stdout__.fileno(),
2 : sys.__stderr__.fileno()})
else:
diff --git a/pym/_emerge/BinpkgFetcher.py b/pym/_emerge/BinpkgFetcher.py
index 1913b44..14f2552 100644
--- a/pym/_emerge/BinpkgFetcher.py
+++ b/pym/_emerge/BinpkgFetcher.py
@@ -91,7 +91,7 @@ class BinpkgFetcher(SpawnProcess):
# Redirect all output to stdout since some fetchers like
# wget pollute stderr (if portage detects a problem then it
# can send it's own message to stderr).
- fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(0, portage._get_stdin().fileno())
fd_pipes.setdefault(1, sys.__stdout__.fileno())
fd_pipes.setdefault(2, sys.__stdout__.fileno())
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index d18512b..45d7095 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -50,7 +50,7 @@ class SpawnProcess(SubProcess):
null_input = os.open('/dev/null', os.O_RDWR)
fd_pipes[0] = null_input
- fd_pipes.setdefault(0, sys.__stdin__.fileno())
+ fd_pipes.setdefault(0, portage._get_stdin().fileno())
fd_pipes.setdefault(1, sys.__stdout__.fileno())
fd_pipes.setdefault(2, sys.__stderr__.fileno())
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 3e634b5..96a4fa9 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -339,6 +339,17 @@ _internal_warnings = False
_sync_disabled_warnings = False
+def _get_stdin():
+ """
+ Buggy code in python's multiprocessing/process.py closes sys.stdin
+ and reassigns it to open(os.devnull), but fails to update the
+ corresponding __stdin__ reference. So, detect that case and handle
+ it appropriately.
+ """
+ if not sys.__stdin__.closed:
+ return sys.__stdin__
+ return sys.stdin
+
def _shell_quote(s):
"""
Quote a string in double-quotes and use backslashes to
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 28b18a0..947bd3e 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -499,7 +499,7 @@ 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(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stdout__.fileno()
}
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index a735ea8..855c62a 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -718,7 +718,7 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
mysettings["dbkey"] = ""
pr, pw = os.pipe()
fd_pipes = {
- 0:sys.__stdin__.fileno(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
9:pw}
@@ -1402,7 +1402,7 @@ 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(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
}
diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
index 59d45be..0a7bf10 100644
--- a/pym/portage/package/ebuild/fetch.py
+++ b/pym/portage/package/ebuild/fetch.py
@@ -64,7 +64,7 @@ def _spawn_fetch(settings, args, **kwargs):
if "fd_pipes" not in kwargs:
kwargs["fd_pipes"] = {
- 0 : sys.__stdin__.fileno(),
+ 0 : portage._get_stdin().fileno(),
1 : sys.__stdout__.fileno(),
2 : sys.__stdout__.fileno(),
}
diff --git a/pym/portage/process.py b/pym/portage/process.py
index fbfbde0..63c3154 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -226,7 +226,7 @@ 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(),
+ 0:portage._get_stdin().fileno(),
1:sys.__stdout__.fileno(),
2:sys.__stderr__.fileno(),
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-15 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-15 22:04 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/portage/, pym/_emerge/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2012-08-22 19:46 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox