Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, bin/, pym/portage/, pym/_emerge/
Date: Wed, 22 Aug 2012 19:46:34
Message-Id: 1345664764.77cb4022c981c3c6ba96533a55058a643f60d334.zmedico@gentoo
1 commit: 77cb4022c981c3c6ba96533a55058a643f60d334
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 22 19:46:04 2012 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 22 19:46:04 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=77cb4022
7
8 Use sys.__std*.fileno() in case of overrides.
9
10 This fixes AttributeError exceptions for API consumers that override
11 sys.std* streams pseudo-file objects.
12
13 ---
14 bin/dispatch-conf | 10 ++++++----
15 pym/_emerge/BinpkgFetcher.py | 10 +++++-----
16 pym/_emerge/EbuildMetadataPhase.py | 12 ++++++------
17 pym/_emerge/SpawnProcess.py | 16 ++++++++--------
18 pym/portage/getbinpkg.py | 8 +++++---
19 pym/portage/package/ebuild/doebuild.py | 18 +++++++++---------
20 pym/portage/package/ebuild/fetch.py | 6 +++---
21 pym/portage/process.py | 6 +++---
22 8 files changed, 45 insertions(+), 41 deletions(-)
23
24 diff --git a/bin/dispatch-conf b/bin/dispatch-conf
25 index 139a001..35979db 100755
26 --- a/bin/dispatch-conf
27 +++ b/bin/dispatch-conf
28 @@ -1,5 +1,5 @@
29 #!/usr/bin/python -O
30 -# Copyright 1999-2011 Gentoo Foundation
31 +# Copyright 1999-2012 Gentoo Foundation
32 # Distributed under the terms of the GNU General Public License v2
33
34 #
35 @@ -463,10 +463,12 @@ if not shell or not os.access(shell, os.EX_OK):
36
37 def spawn_shell(cmd):
38 if shell:
39 + sys.__stdout__.flush()
40 + sys.__stderr__.flush()
41 spawn([shell, "-c", cmd], env=os.environ,
42 - fd_pipes = { 0 : sys.stdin.fileno(),
43 - 1 : sys.stdout.fileno(),
44 - 2 : sys.stderr.fileno()})
45 + fd_pipes = { 0 : sys.__stdin__.fileno(),
46 + 1 : sys.__stdout__.fileno(),
47 + 2 : sys.__stderr__.fileno()})
48 else:
49 os.system(cmd)
50
51
52 diff --git a/pym/_emerge/BinpkgFetcher.py b/pym/_emerge/BinpkgFetcher.py
53 index f415e2e..1913b44 100644
54 --- a/pym/_emerge/BinpkgFetcher.py
55 +++ b/pym/_emerge/BinpkgFetcher.py
56 @@ -1,4 +1,4 @@
57 -# Copyright 1999-2011 Gentoo Foundation
58 +# Copyright 1999-2012 Gentoo Foundation
59 # Distributed under the terms of the GNU General Public License v2
60
61 from _emerge.AsynchronousLock import AsynchronousLock
62 @@ -91,9 +91,9 @@ class BinpkgFetcher(SpawnProcess):
63 # Redirect all output to stdout since some fetchers like
64 # wget pollute stderr (if portage detects a problem then it
65 # can send it's own message to stderr).
66 - fd_pipes.setdefault(0, sys.stdin.fileno())
67 - fd_pipes.setdefault(1, sys.stdout.fileno())
68 - fd_pipes.setdefault(2, sys.stdout.fileno())
69 + fd_pipes.setdefault(0, sys.__stdin__.fileno())
70 + fd_pipes.setdefault(1, sys.__stdout__.fileno())
71 + fd_pipes.setdefault(2, sys.__stdout__.fileno())
72
73 self.args = fetch_args
74 self.env = fetch_env
75 @@ -104,7 +104,7 @@ class BinpkgFetcher(SpawnProcess):
76 def _pipe(self, fd_pipes):
77 """When appropriate, use a pty so that fetcher progress bars,
78 like wget has, will work properly."""
79 - if self.background or not sys.stdout.isatty():
80 + if self.background or not sys.__stdout__.isatty():
81 # When the output only goes to a log file,
82 # there's no point in creating a pty.
83 return os.pipe()
84
85 diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py
86 index c2d3747..d49c51f 100644
87 --- a/pym/_emerge/EbuildMetadataPhase.py
88 +++ b/pym/_emerge/EbuildMetadataPhase.py
89 @@ -74,15 +74,15 @@ class EbuildMetadataPhase(SubProcess):
90
91 null_input = open('/dev/null', 'rb')
92 fd_pipes.setdefault(0, null_input.fileno())
93 - fd_pipes.setdefault(1, sys.stdout.fileno())
94 - fd_pipes.setdefault(2, sys.stderr.fileno())
95 + fd_pipes.setdefault(1, sys.__stdout__.fileno())
96 + fd_pipes.setdefault(2, sys.__stderr__.fileno())
97
98 # flush any pending output
99 for fd in fd_pipes.values():
100 - if fd == sys.stdout.fileno():
101 - sys.stdout.flush()
102 - if fd == sys.stderr.fileno():
103 - sys.stderr.flush()
104 + if fd == sys.__stdout__.fileno():
105 + sys.__stdout__.flush()
106 + if fd == sys.__stderr__.fileno():
107 + sys.__stderr__.flush()
108
109 self._files = self._files_dict()
110 files = self._files
111
112 diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
113 index 9fbc964..dfcf088 100644
114 --- a/pym/_emerge/SpawnProcess.py
115 +++ b/pym/_emerge/SpawnProcess.py
116 @@ -1,4 +1,4 @@
117 -# Copyright 1999-2011 Gentoo Foundation
118 +# Copyright 1999-2012 Gentoo Foundation
119 # Distributed under the terms of the GNU General Public License v2
120
121 from _emerge.SubProcess import SubProcess
122 @@ -62,16 +62,16 @@ class SpawnProcess(SubProcess):
123 null_input = os.open('/dev/null', os.O_RDWR)
124 fd_pipes[0] = null_input
125
126 - fd_pipes.setdefault(0, sys.stdin.fileno())
127 - fd_pipes.setdefault(1, sys.stdout.fileno())
128 - fd_pipes.setdefault(2, sys.stderr.fileno())
129 + fd_pipes.setdefault(0, sys.__stdin__.fileno())
130 + fd_pipes.setdefault(1, sys.__stdout__.fileno())
131 + fd_pipes.setdefault(2, sys.__stderr__.fileno())
132
133 # flush any pending output
134 for fd in fd_pipes.values():
135 - if fd == sys.stdout.fileno():
136 - sys.stdout.flush()
137 - if fd == sys.stderr.fileno():
138 - sys.stderr.flush()
139 + if fd == sys.__stdout__.fileno():
140 + sys.__stdout__.flush()
141 + if fd == sys.__stderr__.fileno():
142 + sys.__stderr__.flush()
143
144 if logfile is not None:
145
146
147 diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
148 index 212f788..34a5e0e 100644
149 --- a/pym/portage/getbinpkg.py
150 +++ b/pym/portage/getbinpkg.py
151 @@ -466,10 +466,12 @@ def file_get(baseurl,dest,conn=None,fcmd=None,filename=None):
152 myfetch = portage.util.shlex_split(fcmd)
153 myfetch = [varexpand(x, mydict=variables) for x in myfetch]
154 fd_pipes= {
155 - 0:sys.stdin.fileno(),
156 - 1:sys.stdout.fileno(),
157 - 2:sys.stdout.fileno()
158 + 0:sys.__stdin__.fileno(),
159 + 1:sys.__stdout__.fileno(),
160 + 2:sys.__stdout__.fileno()
161 }
162 + sys.__stdout__.flush()
163 + sys.__stderr__.flush()
164 retval = spawn(myfetch, env=os.environ.copy(), fd_pipes=fd_pipes)
165 if retval != os.EX_OK:
166 sys.stderr.write(_("Fetcher exited with a failure condition.\n"))
167
168 diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
169 index 395e0ee..ef51da1 100644
170 --- a/pym/portage/package/ebuild/doebuild.py
171 +++ b/pym/portage/package/ebuild/doebuild.py
172 @@ -690,9 +690,9 @@ def doebuild(myebuild, mydo, _unused=None, settings=None, debug=0, listonly=0,
173 mysettings["dbkey"] = ""
174 pr, pw = os.pipe()
175 fd_pipes = {
176 - 0:sys.stdin.fileno(),
177 - 1:sys.stdout.fileno(),
178 - 2:sys.stderr.fileno(),
179 + 0:sys.__stdin__.fileno(),
180 + 1:sys.__stdout__.fileno(),
181 + 2:sys.__stderr__.fileno(),
182 9:pw}
183 mypids = _spawn_phase(mydo, mysettings, returnpid=True,
184 fd_pipes=fd_pipes)
185 @@ -1367,18 +1367,18 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
186 fd_pipes = keywords.get("fd_pipes")
187 if fd_pipes is None:
188 fd_pipes = {
189 - 0:sys.stdin.fileno(),
190 - 1:sys.stdout.fileno(),
191 - 2:sys.stderr.fileno(),
192 + 0:sys.__stdin__.fileno(),
193 + 1:sys.__stdout__.fileno(),
194 + 2:sys.__stderr__.fileno(),
195 }
196 # In some cases the above print statements don't flush stdout, so
197 # it needs to be flushed before allowing a child process to use it
198 # so that output always shows in the correct order.
199 - stdout_filenos = (sys.stdout.fileno(), sys.stderr.fileno())
200 + stdout_filenos = (sys.__stdout__.fileno(), sys.__stderr__.fileno())
201 for fd in fd_pipes.values():
202 if fd in stdout_filenos:
203 - sys.stdout.flush()
204 - sys.stderr.flush()
205 + sys.__stdout__.flush()
206 + sys.__stderr__.flush()
207 break
208
209 features = mysettings.features
210
211 diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
212 index 576a912..260bf10 100644
213 --- a/pym/portage/package/ebuild/fetch.py
214 +++ b/pym/portage/package/ebuild/fetch.py
215 @@ -64,9 +64,9 @@ def _spawn_fetch(settings, args, **kwargs):
216 if "fd_pipes" not in kwargs:
217
218 kwargs["fd_pipes"] = {
219 - 0 : sys.stdin.fileno(),
220 - 1 : sys.stdout.fileno(),
221 - 2 : sys.stdout.fileno(),
222 + 0 : sys.__stdin__.fileno(),
223 + 1 : sys.__stdout__.fileno(),
224 + 2 : sys.__stdout__.fileno(),
225 }
226
227 if "userfetch" in settings.features and \
228
229 diff --git a/pym/portage/process.py b/pym/portage/process.py
230 index f3cec88..32e60ac 100644
231 --- a/pym/portage/process.py
232 +++ b/pym/portage/process.py
233 @@ -226,9 +226,9 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
234 # default to propagating our stdin, stdout and stderr.
235 if fd_pipes is None:
236 fd_pipes = {
237 - 0:sys.stdin.fileno(),
238 - 1:sys.stdout.fileno(),
239 - 2:sys.stderr.fileno(),
240 + 0:sys.__stdin__.fileno(),
241 + 1:sys.__stdout__.fileno(),
242 + 2:sys.__stderr__.fileno(),
243 }
244
245 # mypids will hold the pids of all processes created.