Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/util/_eventloop/, pym/portage/util/_async/, ...
Date: Mon, 02 Sep 2013 14:00:42
Message-Id: 1378130189.cd0eec80a70e5c5de2c39be5e767a4ce27083372.arfrever@gentoo
1 commit: cd0eec80a70e5c5de2c39be5e767a4ce27083372
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Mon Sep 2 13:56:29 2013 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
5 CommitDate: Mon Sep 2 13:56:29 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cd0eec80
7
8 Disable calls to fcntl.fcntl(…, fcntl.F_SETFD, … | fcntl.FD_CLOEXEC) with Python >=3.4,
9 since FD_CLOEXEC is enabled by default in Python >=3.4.
10
11 ---
12 pym/_emerge/AsynchronousLock.py | 16 +++++++++-------
13 pym/_emerge/EbuildMetadataPhase.py | 16 +++++++++-------
14 pym/_emerge/FifoIpcDaemon.py | 8 ++++++--
15 pym/_emerge/PipeReader.py | 22 ++++++++++++++--------
16 pym/_emerge/SpawnProcess.py | 3 ++-
17 pym/portage/dbapi/_MergeProcess.py | 16 +++++++++-------
18 pym/portage/locks.py | 16 +++++++++-------
19 pym/portage/util/_async/PipeLogger.py | 17 ++++++++++-------
20 pym/portage/util/_eventloop/EventLoop.py | 22 +++++++++++++---------
21 9 files changed, 81 insertions(+), 55 deletions(-)
22
23 diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py
24 index cfe98b0..c0b9b26 100644
25 --- a/pym/_emerge/AsynchronousLock.py
26 +++ b/pym/_emerge/AsynchronousLock.py
27 @@ -168,13 +168,15 @@ class _LockProcess(AbstractPollTask):
28 fcntl.fcntl(in_pr, fcntl.F_SETFL,
29 fcntl.fcntl(in_pr, fcntl.F_GETFL) | os.O_NONBLOCK)
30
31 - try:
32 - fcntl.FD_CLOEXEC
33 - except AttributeError:
34 - pass
35 - else:
36 - fcntl.fcntl(in_pr, fcntl.F_SETFD,
37 - fcntl.fcntl(in_pr, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
38 + # FD_CLOEXEC is enabled by default in Python >=3.4.
39 + if sys.hexversion < 0x3040000:
40 + try:
41 + fcntl.FD_CLOEXEC
42 + except AttributeError:
43 + pass
44 + else:
45 + fcntl.fcntl(in_pr, fcntl.F_SETFD,
46 + fcntl.fcntl(in_pr, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
47
48 self._reg_id = self.scheduler.io_add_watch(in_pr,
49 self.scheduler.IO_IN, self._output_handler)
50
51 diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py
52 index 7882b63..bbb1ca9 100644
53 --- a/pym/_emerge/EbuildMetadataPhase.py
54 +++ b/pym/_emerge/EbuildMetadataPhase.py
55 @@ -94,13 +94,15 @@ class EbuildMetadataPhase(SubProcess):
56 fcntl.fcntl(master_fd, fcntl.F_SETFL,
57 fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
58
59 - try:
60 - fcntl.FD_CLOEXEC
61 - except AttributeError:
62 - pass
63 - else:
64 - fcntl.fcntl(master_fd, fcntl.F_SETFD,
65 - fcntl.fcntl(master_fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
66 + # FD_CLOEXEC is enabled by default in Python >=3.4.
67 + if sys.hexversion < 0x3040000:
68 + try:
69 + fcntl.FD_CLOEXEC
70 + except AttributeError:
71 + pass
72 + else:
73 + fcntl.fcntl(master_fd, fcntl.F_SETFD,
74 + fcntl.fcntl(master_fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
75
76 fd_pipes[slave_fd] = slave_fd
77 settings["PORTAGE_PIPE_FD"] = str(slave_fd)
78
79 diff --git a/pym/_emerge/FifoIpcDaemon.py b/pym/_emerge/FifoIpcDaemon.py
80 index 662aec1..7468de5 100644
81 --- a/pym/_emerge/FifoIpcDaemon.py
82 +++ b/pym/_emerge/FifoIpcDaemon.py
83 @@ -1,6 +1,8 @@
84 # Copyright 2010-2013 Gentoo Foundation
85 # Distributed under the terms of the GNU General Public License v2
86
87 +import sys
88 +
89 try:
90 import fcntl
91 except ImportError:
92 @@ -27,7 +29,8 @@ class FifoIpcDaemon(AbstractPollTask):
93 self._files.pipe_in = \
94 os.open(self.input_fifo, os.O_RDONLY|os.O_NONBLOCK)
95
96 - if fcntl is not None:
97 + # FD_CLOEXEC is enabled by default in Python >=3.4.
98 + if sys.hexversion < 0x3040000 and fcntl is not None:
99 try:
100 fcntl.FD_CLOEXEC
101 except AttributeError:
102 @@ -53,7 +56,8 @@ class FifoIpcDaemon(AbstractPollTask):
103 self._files.pipe_in = \
104 os.open(self.input_fifo, os.O_RDONLY|os.O_NONBLOCK)
105
106 - if fcntl is not None:
107 + # FD_CLOEXEC is enabled by default in Python >=3.4.
108 + if sys.hexversion < 0x3040000 and fcntl is not None:
109 try:
110 fcntl.FD_CLOEXEC
111 except AttributeError:
112
113 diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
114 index c7eef1d..a8392c3 100644
115 --- a/pym/_emerge/PipeReader.py
116 +++ b/pym/_emerge/PipeReader.py
117 @@ -1,9 +1,11 @@
118 # Copyright 1999-2013 Gentoo Foundation
119 # Distributed under the terms of the GNU General Public License v2
120
121 +import fcntl
122 +import sys
123 +
124 from portage import os
125 from _emerge.AbstractPollTask import AbstractPollTask
126 -import fcntl
127
128 class PipeReader(AbstractPollTask):
129
130 @@ -30,13 +32,17 @@ class PipeReader(AbstractPollTask):
131 fd = isinstance(f, int) and f or f.fileno()
132 fcntl.fcntl(fd, fcntl.F_SETFL,
133 fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
134 - try:
135 - fcntl.FD_CLOEXEC
136 - except AttributeError:
137 - pass
138 - else:
139 - fcntl.fcntl(fd, fcntl.F_SETFD,
140 - fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
141 +
142 + # FD_CLOEXEC is enabled by default in Python >=3.4.
143 + if sys.hexversion < 0x3040000:
144 + try:
145 + fcntl.FD_CLOEXEC
146 + except AttributeError:
147 + pass
148 + else:
149 + fcntl.fcntl(fd, fcntl.F_SETFD,
150 + fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
151 +
152 self._reg_ids.add(self.scheduler.io_add_watch(fd,
153 self._registered_events, output_handler))
154 self._registered = True
155
156 diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
157 index 2c2e1a9..c7872ca 100644
158 --- a/pym/_emerge/SpawnProcess.py
159 +++ b/pym/_emerge/SpawnProcess.py
160 @@ -125,7 +125,8 @@ class SpawnProcess(SubProcess):
161 stdout_fd = None
162 if can_log and not self.background:
163 stdout_fd = os.dup(fd_pipes_orig[1])
164 - if fcntl is not None and not _disable_cloexec_stdout:
165 + # FD_CLOEXEC is enabled by default in Python >=3.4.
166 + if sys.hexversion < 0x3040000 and fcntl is not None and not _disable_cloexec_stdout:
167 try:
168 fcntl.FD_CLOEXEC
169 except AttributeError:
170
171 diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
172 index d7280f0..956dbb9 100644
173 --- a/pym/portage/dbapi/_MergeProcess.py
174 +++ b/pym/portage/dbapi/_MergeProcess.py
175 @@ -120,13 +120,15 @@ class MergeProcess(ForkProcess):
176 fcntl.fcntl(elog_reader_fd, fcntl.F_SETFL,
177 fcntl.fcntl(elog_reader_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
178
179 - try:
180 - fcntl.FD_CLOEXEC
181 - except AttributeError:
182 - pass
183 - else:
184 - fcntl.fcntl(elog_reader_fd, fcntl.F_SETFD,
185 - fcntl.fcntl(elog_reader_fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
186 + # FD_CLOEXEC is enabled by default in Python >=3.4.
187 + if sys.hexversion < 0x3040000:
188 + try:
189 + fcntl.FD_CLOEXEC
190 + except AttributeError:
191 + pass
192 + else:
193 + fcntl.fcntl(elog_reader_fd, fcntl.F_SETFD,
194 + fcntl.fcntl(elog_reader_fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
195
196 blockers = None
197 if self.blockers is not None:
198
199 diff --git a/pym/portage/locks.py b/pym/portage/locks.py
200 index 4f356c9..8571d8c 100644
201 --- a/pym/portage/locks.py
202 +++ b/pym/portage/locks.py
203 @@ -234,13 +234,15 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
204
205 if myfd != HARDLINK_FD:
206
207 - try:
208 - fcntl.FD_CLOEXEC
209 - except AttributeError:
210 - pass
211 - else:
212 - fcntl.fcntl(myfd, fcntl.F_SETFD,
213 - fcntl.fcntl(myfd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
214 + # FD_CLOEXEC is enabled by default in Python >=3.4.
215 + if sys.hexversion < 0x3040000:
216 + try:
217 + fcntl.FD_CLOEXEC
218 + except AttributeError:
219 + pass
220 + else:
221 + fcntl.fcntl(myfd, fcntl.F_SETFD,
222 + fcntl.fcntl(myfd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
223
224 _open_fds.add(myfd)
225
226
227 diff --git a/pym/portage/util/_async/PipeLogger.py b/pym/portage/util/_async/PipeLogger.py
228 index 06d8200..aa605d9 100644
229 --- a/pym/portage/util/_async/PipeLogger.py
230 +++ b/pym/portage/util/_async/PipeLogger.py
231 @@ -4,6 +4,7 @@
232 import fcntl
233 import errno
234 import gzip
235 +import sys
236
237 import portage
238 from portage import os, _encodings, _unicode_encode
239 @@ -46,13 +47,15 @@ class PipeLogger(AbstractPollTask):
240 fcntl.fcntl(fd, fcntl.F_SETFL,
241 fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
242
243 - try:
244 - fcntl.FD_CLOEXEC
245 - except AttributeError:
246 - pass
247 - else:
248 - fcntl.fcntl(fd, fcntl.F_SETFD,
249 - fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
250 + # FD_CLOEXEC is enabled by default in Python >=3.4.
251 + if sys.hexversion < 0x3040000:
252 + try:
253 + fcntl.FD_CLOEXEC
254 + except AttributeError:
255 + pass
256 + else:
257 + fcntl.fcntl(fd, fcntl.F_SETFD,
258 + fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
259
260 self._reg_id = self.scheduler.io_add_watch(fd,
261 self._registered_events, self._output_handler)
262
263 diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py
264 index 46a1f09..9ffcc74 100644
265 --- a/pym/portage/util/_eventloop/EventLoop.py
266 +++ b/pym/portage/util/_eventloop/EventLoop.py
267 @@ -6,6 +6,7 @@ import logging
268 import os
269 import select
270 import signal
271 +import sys
272 import time
273
274 try:
275 @@ -85,7 +86,8 @@ class EventLoop(object):
276 pass
277 else:
278
279 - if fcntl is not None:
280 + # FD_CLOEXEC is enabled by default in Python >=3.4.
281 + if sys.hexversion < 0x3040000 and fcntl is not None:
282 try:
283 fcntl.FD_CLOEXEC
284 except AttributeError:
285 @@ -319,14 +321,16 @@ class EventLoop(object):
286 fcntl.fcntl(self._sigchld_read,
287 fcntl.F_GETFL) | os.O_NONBLOCK)
288
289 - try:
290 - fcntl.FD_CLOEXEC
291 - except AttributeError:
292 - pass
293 - else:
294 - fcntl.fcntl(self._sigchld_read, fcntl.F_SETFD,
295 - fcntl.fcntl(self._sigchld_read,
296 - fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
297 + # FD_CLOEXEC is enabled by default in Python >=3.4.
298 + if sys.hexversion < 0x3040000:
299 + try:
300 + fcntl.FD_CLOEXEC
301 + except AttributeError:
302 + pass
303 + else:
304 + fcntl.fcntl(self._sigchld_read, fcntl.F_SETFD,
305 + fcntl.fcntl(self._sigchld_read,
306 + fcntl.F_GETFD) | fcntl.FD_CLOEXEC)
307
308 # The IO watch is dynamically registered and unregistered as
309 # needed, since we don't want to consider it as a valid source