From: Zac Medico Date: Sun, 7 Jul 2013 18:14:09 +0000 (-0700) Subject: Use sys.__std* streams for fileno(). X-Git-Tag: v2.2.0_alpha187~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=66a6b6e582c232a026abc394f5144a05ba1479f7;p=portage.git Use sys.__std* streams for fileno(). --- diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py index fd66a9455..c2dbf2d3c 100644 --- a/pym/_emerge/AsynchronousLock.py +++ b/pym/_emerge/AsynchronousLock.py @@ -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() diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 5c67f032b..51952f69e 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -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, diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py index 0c207762e..fba61e82f 100644 --- a/pym/portage/dbapi/_MergeProcess.py +++ b/pym/portage/dbapi/_MergeProcess.py @@ -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() diff --git a/pym/portage/output.py b/pym/portage/output.py index e44375ee3..20471bccb 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -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 diff --git a/pym/portage/tests/ebuild/test_spawn.py b/pym/portage/tests/ebuild/test_spawn.py index 3a07b150a..a38e10972 100644 --- a/pym/portage/tests/ebuild/test_spawn.py +++ b/pym/portage/tests/ebuild/test_spawn.py @@ -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()