Use sys.__std* streams for fileno().
authorZac Medico <zmedico@gentoo.org>
Sun, 7 Jul 2013 18:14:09 +0000 (11:14 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 7 Jul 2013 18:20:49 +0000 (11:20 -0700)
pym/_emerge/AsynchronousLock.py
pym/_emerge/EbuildPhase.py
pym/portage/dbapi/_MergeProcess.py
pym/portage/output.py
pym/portage/tests/ebuild/test_spawn.py

index fd66a945596e4a017e1d1328f1439f3628f56ead..c2dbf2d3c4311e0e7adb0f1a226a4fa579217a39 100644 (file)
@@ -182,7 +182,7 @@ class _LockProcess(AbstractPollTask):
                        args=[portage._python_interpreter,
                                os.path.join(portage._bin_path, 'lock-helper.py'), self.path],
                                env=dict(os.environ, PORTAGE_PYM_PATH=portage._pym_path),
-                               fd_pipes={0:out_pr, 1:in_pw, 2:sys.stderr.fileno()},
+                               fd_pipes={0:out_pr, 1:in_pw, 2:sys.__stderr__.fileno()},
                                scheduler=self.scheduler)
                self._proc.addExitListener(self._proc_exit)
                self._proc.start()
index 5c67f032babedecb2f9b133effa2adbb57b28745..51952f69e1df1e97e96541c5d2f7f9f7661e3fce 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import gzip
@@ -174,7 +174,7 @@ class EbuildPhase(CompositeTask):
                        if not self.background and self.phase == 'nofetch':
                                # All the pkg_nofetch output goes to stderr since
                                # it's considered to be an error message.
-                               fd_pipes = {1 : sys.stderr.fileno()}
+                               fd_pipes = {1 : sys.__stderr__.fileno()}
 
                ebuild_process = EbuildProcess(actionmap=self.actionmap,
                        background=self.background, fd_pipes=fd_pipes,
index 0c207762e3bad4135a4cfbf24e02684166bd240c..fba61e82f9df86c51b8fb480fcf9aa37b1bfee5c 100644 (file)
@@ -55,7 +55,7 @@ class MergeProcess(ForkProcess):
                        self.fd_pipes = {}
                else:
                        self.fd_pipes = self.fd_pipes.copy()
-               self.fd_pipes.setdefault(0, sys.stdin.fileno())
+               self.fd_pipes.setdefault(0, portage._get_stdin().fileno())
 
                super(MergeProcess, self)._start()
 
index e44375ee38451ba304d14a054a5fd6752027cafe..20471bccb63aac6582613525465c0206c2375bc8 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __docformat__ = "epytext"
@@ -245,7 +245,7 @@ _max_xtermTitle_len = 253
 def xtermTitle(mystr, raw=False):
        global _disable_xtermTitle
        if _disable_xtermTitle is None:
-               _disable_xtermTitle = not (sys.stderr.isatty() and \
+               _disable_xtermTitle = not (sys.__stderr__.isatty() and \
                'TERM' in os.environ and \
                _legal_terms_re.match(os.environ['TERM']) is not None)
 
@@ -278,15 +278,18 @@ def xtermTitleReset():
                        if dotitles and \
                                'TERM' in os.environ and \
                                _legal_terms_re.match(os.environ['TERM']) is not None and \
-                               sys.stderr.isatty():
+                               sys.__stderr__.isatty():
                                from portage.process import find_binary, spawn
                                shell = os.environ.get("SHELL")
                                if not shell or not os.access(shell, os.EX_OK):
                                        shell = find_binary("sh")
                                if shell:
                                        spawn([shell, "-c", prompt_command], env=os.environ,
-                                               fd_pipes={0:sys.stdin.fileno(),1:sys.stderr.fileno(),
-                                               2:sys.stderr.fileno()})
+                                               fd_pipes={
+                                                       0: portage._get_stdin().fileno(),
+                                                       1: sys.__stderr__.fileno(),
+                                                       2: sys.__stderr__.fileno()
+                                               })
                                else:
                                        os.system(prompt_command)
                        return
index 3a07b150a9555ec09403f17f954e6745f7bf753b..a38e109721e1543289467c3547a985a771056ae6 100644 (file)
@@ -1,10 +1,11 @@
-# Copyright 1998-2011 Gentoo Foundation
+# Copyright 1998-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import errno
 import io
 import sys
 import tempfile
+import portage
 from portage import os
 from portage import _encodings
 from portage import _unicode_encode
@@ -25,7 +26,12 @@ class SpawnTestCase(TestCase):
                        proc = SpawnProcess(
                                args=[BASH_BINARY, "-c",
                                "echo -n '%s'" % test_string],
-                               env={}, fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd},
+                               env={},
+                               fd_pipes={
+                                       0: portage._get_stdin().fileno(),
+                                       1: null_fd,
+                                       2: null_fd
+                               },
                                scheduler=global_event_loop(),
                                logfile=logfile)
                        proc.start()