1 |
--- |
2 |
bin/binhost-snapshot | 5 +-- |
3 |
lib/_emerge/BinpkgFetcher.py | 5 +-- |
4 |
lib/_emerge/BlockerCache.py | 6 +--- |
5 |
lib/portage/cache/anydbm.py | 31 +++++----------- |
6 |
lib/portage/dbapi/bintree.py | 5 +-- |
7 |
lib/portage/dbapi/porttree.py | 6 +--- |
8 |
lib/portage/dbapi/vartree.py | 6 +--- |
9 |
lib/portage/getbinpkg.py | 36 +++++-------------- |
10 |
lib/portage/glsa.py | 5 +-- |
11 |
lib/portage/package/ebuild/fetch.py | 12 ++----- |
12 |
.../asyncio/test_policy_wrapper_recursion.py | 8 +---- |
13 |
lib/portage/tests/util/futures/test_retry.py | 5 +-- |
14 |
lib/portage/tests/util/test_socks5.py | 11 ++---- |
15 |
lib/portage/tests/util/test_xattr.py | 14 +------- |
16 |
lib/portage/util/__init__.py | 5 +-- |
17 |
.../util/_dyn_libs/PreservedLibsRegistry.py | 6 +--- |
18 |
lib/portage/util/_eventloop/EventLoop.py | 10 ++---- |
19 |
.../util/_eventloop/asyncio_event_loop.py | 9 ++--- |
20 |
lib/portage/util/_urlopen.py | 12 ++----- |
21 |
lib/portage/util/futures/_asyncio/__init__.py | 7 ++-- |
22 |
lib/portage/util/futures/_asyncio/tasks.py | 7 +--- |
23 |
lib/portage/util/futures/events.py | 12 +++---- |
24 |
lib/portage/util/futures/futures.py | 36 ++++--------------- |
25 |
lib/portage/util/futures/transports.py | 5 +-- |
26 |
lib/portage/util/futures/unix_events.py | 21 ++++------- |
27 |
25 files changed, 61 insertions(+), 224 deletions(-) |
28 |
|
29 |
diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot |
30 |
index d677e7568..afab23592 100755 |
31 |
--- a/bin/binhost-snapshot |
32 |
+++ b/bin/binhost-snapshot |
33 |
@@ -8,10 +8,7 @@ import os |
34 |
import sys |
35 |
import textwrap |
36 |
|
37 |
-try: |
38 |
- from urllib.parse import urlparse |
39 |
-except ImportError: |
40 |
- from urlparse import urlparse |
41 |
+from urllib.parse import urlparse |
42 |
|
43 |
from os import path as osp |
44 |
if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".portage_not_installed")): |
45 |
diff --git a/lib/_emerge/BinpkgFetcher.py b/lib/_emerge/BinpkgFetcher.py |
46 |
index c26c9bd6b..01c9bc1e6 100644 |
47 |
--- a/lib/_emerge/BinpkgFetcher.py |
48 |
+++ b/lib/_emerge/BinpkgFetcher.py |
49 |
@@ -6,10 +6,7 @@ import functools |
50 |
from _emerge.AsynchronousLock import AsynchronousLock |
51 |
from _emerge.CompositeTask import CompositeTask |
52 |
from _emerge.SpawnProcess import SpawnProcess |
53 |
-try: |
54 |
- from urllib.parse import urlparse as urllib_parse_urlparse |
55 |
-except ImportError: |
56 |
- from urlparse import urlparse as urllib_parse_urlparse |
57 |
+from urllib.parse import urlparse as urllib_parse_urlparse |
58 |
import stat |
59 |
import sys |
60 |
import portage |
61 |
diff --git a/lib/_emerge/BlockerCache.py b/lib/_emerge/BlockerCache.py |
62 |
index d0beb46ac..5f8fb360e 100644 |
63 |
--- a/lib/_emerge/BlockerCache.py |
64 |
+++ b/lib/_emerge/BlockerCache.py |
65 |
@@ -7,11 +7,7 @@ from portage.util import writemsg |
66 |
from portage.data import secpass |
67 |
import portage |
68 |
from portage import os |
69 |
- |
70 |
-try: |
71 |
- import cPickle as pickle |
72 |
-except ImportError: |
73 |
- import pickle |
74 |
+import pickle |
75 |
|
76 |
class BlockerCache(portage.cache.mappings.MutableMapping): |
77 |
"""This caches blockers of installed packages so that dep_check does not |
78 |
diff --git a/lib/portage/cache/anydbm.py b/lib/portage/cache/anydbm.py |
79 |
index 121a4eaf2..c02d85b4f 100644 |
80 |
--- a/lib/portage/cache/anydbm.py |
81 |
+++ b/lib/portage/cache/anydbm.py |
82 |
@@ -4,29 +4,14 @@ |
83 |
|
84 |
from __future__ import absolute_import |
85 |
|
86 |
-try: |
87 |
- import anydbm as anydbm_module |
88 |
-except ImportError: |
89 |
- # python 3.x |
90 |
- import dbm as anydbm_module |
91 |
+import dbm |
92 |
|
93 |
try: |
94 |
import dbm.gnu as gdbm |
95 |
except ImportError: |
96 |
- try: |
97 |
- import gdbm |
98 |
- except ImportError: |
99 |
- gdbm = None |
100 |
+ gdbm = None |
101 |
|
102 |
-try: |
103 |
- from dbm import whichdb |
104 |
-except ImportError: |
105 |
- from whichdb import whichdb |
106 |
- |
107 |
-try: |
108 |
- import cPickle as pickle |
109 |
-except ImportError: |
110 |
- import pickle |
111 |
+import pickle |
112 |
from portage import _unicode_encode |
113 |
from portage import os |
114 |
import sys |
115 |
@@ -53,15 +38,15 @@ class database(fs_template.FsBased): |
116 |
self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+default_db) |
117 |
self.__db = None |
118 |
mode = "w" |
119 |
- if whichdb(self._db_path) in ("dbm.gnu", "gdbm"): |
120 |
+ if dbm.whichdb(self._db_path) in ("dbm.gnu", "gdbm"): |
121 |
# Allow multiple concurrent writers (see bug #53607). |
122 |
mode += "u" |
123 |
try: |
124 |
# dbm.open() will not work with bytes in python-3.1: |
125 |
# TypeError: can't concat bytes to str |
126 |
- self.__db = anydbm_module.open(self._db_path, |
127 |
+ self.__db = dbm.open(self._db_path, |
128 |
mode, self._perms) |
129 |
- except anydbm_module.error: |
130 |
+ except dbm.error: |
131 |
# XXX handle this at some point |
132 |
try: |
133 |
self._ensure_dirs() |
134 |
@@ -75,14 +60,14 @@ class database(fs_template.FsBased): |
135 |
# dbm.open() will not work with bytes in python-3.1: |
136 |
# TypeError: can't concat bytes to str |
137 |
if gdbm is None: |
138 |
- self.__db = anydbm_module.open(self._db_path, |
139 |
+ self.__db = dbm.open(self._db_path, |
140 |
"c", self._perms) |
141 |
else: |
142 |
# Prefer gdbm type if available, since it allows |
143 |
# multiple concurrent writers (see bug #53607). |
144 |
self.__db = gdbm.open(self._db_path, |
145 |
"cu", self._perms) |
146 |
- except anydbm_module.error as e: |
147 |
+ except dbm.error as e: |
148 |
raise cache_errors.InitializationError(self.__class__, e) |
149 |
self._ensure_access(self._db_path) |
150 |
|
151 |
diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py |
152 |
index 49e17721b..f6defbc30 100644 |
153 |
--- a/lib/portage/dbapi/bintree.py |
154 |
+++ b/lib/portage/dbapi/bintree.py |
155 |
@@ -52,10 +52,7 @@ import traceback |
156 |
import warnings |
157 |
from gzip import GzipFile |
158 |
from itertools import chain |
159 |
-try: |
160 |
- from urllib.parse import urlparse |
161 |
-except ImportError: |
162 |
- from urlparse import urlparse |
163 |
+from urllib.parse import urlparse |
164 |
|
165 |
|
166 |
class UseCachedCopyOfRemoteIndex(Exception): |
167 |
diff --git a/lib/portage/dbapi/porttree.py b/lib/portage/dbapi/porttree.py |
168 |
index 4916114cd..d220292a8 100644 |
169 |
--- a/lib/portage/dbapi/porttree.py |
170 |
+++ b/lib/portage/dbapi/porttree.py |
171 |
@@ -47,11 +47,7 @@ import collections |
172 |
import functools |
173 |
|
174 |
from collections import OrderedDict |
175 |
- |
176 |
-try: |
177 |
- from urllib.parse import urlparse |
178 |
-except ImportError: |
179 |
- from urlparse import urlparse |
180 |
+from urllib.parse import urlparse |
181 |
|
182 |
|
183 |
def close_portdbapi_caches(): |
184 |
diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py |
185 |
index 2e29b25e5..bb2dd1424 100644 |
186 |
--- a/lib/portage/dbapi/vartree.py |
187 |
+++ b/lib/portage/dbapi/vartree.py |
188 |
@@ -92,6 +92,7 @@ from itertools import chain |
189 |
import logging |
190 |
import os as _os |
191 |
import operator |
192 |
+import pickle |
193 |
import platform |
194 |
import pwd |
195 |
import re |
196 |
@@ -102,11 +103,6 @@ import textwrap |
197 |
import time |
198 |
import warnings |
199 |
|
200 |
-try: |
201 |
- import cPickle as pickle |
202 |
-except ImportError: |
203 |
- import pickle |
204 |
- |
205 |
|
206 |
class vardbapi(dbapi): |
207 |
|
208 |
diff --git a/lib/portage/getbinpkg.py b/lib/portage/getbinpkg.py |
209 |
index f8c1dfd7c..03522689b 100644 |
210 |
--- a/lib/portage/getbinpkg.py |
211 |
+++ b/lib/portage/getbinpkg.py |
212 |
@@ -13,6 +13,7 @@ from portage import _unicode_encode |
213 |
from portage.package.ebuild.fetch import _hide_url_passwd |
214 |
from _emerge.Package import _all_metadata_keys |
215 |
|
216 |
+import pickle |
217 |
import sys |
218 |
import socket |
219 |
import time |
220 |
@@ -22,20 +23,8 @@ import warnings |
221 |
|
222 |
_all_errors = [NotImplementedError, ValueError, socket.error] |
223 |
|
224 |
-try: |
225 |
- from html.parser import HTMLParser as html_parser_HTMLParser |
226 |
-except ImportError: |
227 |
- from HTMLParser import HTMLParser as html_parser_HTMLParser |
228 |
- |
229 |
-try: |
230 |
- from urllib.parse import unquote as urllib_parse_unquote |
231 |
-except ImportError: |
232 |
- from urllib2 import unquote as urllib_parse_unquote |
233 |
- |
234 |
-try: |
235 |
- import cPickle as pickle |
236 |
-except ImportError: |
237 |
- import pickle |
238 |
+from html.parser import HTMLParser as html_parser_HTMLParser |
239 |
+from urllib.parse import unquote as urllib_parse_unquote |
240 |
|
241 |
try: |
242 |
import ftplib |
243 |
@@ -45,16 +34,10 @@ else: |
244 |
_all_errors.extend(ftplib.all_errors) |
245 |
|
246 |
try: |
247 |
- try: |
248 |
- from http.client import HTTPConnection as http_client_HTTPConnection |
249 |
- from http.client import BadStatusLine as http_client_BadStatusLine |
250 |
- from http.client import ResponseNotReady as http_client_ResponseNotReady |
251 |
- from http.client import error as http_client_error |
252 |
- except ImportError: |
253 |
- from httplib import HTTPConnection as http_client_HTTPConnection |
254 |
- from httplib import BadStatusLine as http_client_BadStatusLine |
255 |
- from httplib import ResponseNotReady as http_client_ResponseNotReady |
256 |
- from httplib import error as http_client_error |
257 |
+ from http.client import HTTPConnection as http_client_HTTPConnection |
258 |
+ from http.client import BadStatusLine as http_client_BadStatusLine |
259 |
+ from http.client import ResponseNotReady as http_client_ResponseNotReady |
260 |
+ from http.client import error as http_client_error |
261 |
except ImportError as e: |
262 |
sys.stderr.write(colorize("BAD", "!!! CANNOT IMPORT HTTP.CLIENT: ") + str(e) + "\n") |
263 |
else: |
264 |
@@ -188,10 +171,7 @@ def create_conn(baseurl, conn=None): |
265 |
# http.client ImportError handler (like during stage1 -> stage2 |
266 |
# builds where USE=ssl is disabled for python). |
267 |
try: |
268 |
- try: |
269 |
- from http.client import HTTPSConnection as http_client_HTTPSConnection |
270 |
- except ImportError: |
271 |
- from httplib import HTTPSConnection as http_client_HTTPSConnection |
272 |
+ from http.client import HTTPSConnection as http_client_HTTPSConnection |
273 |
except ImportError: |
274 |
raise NotImplementedError( |
275 |
_("python must have ssl enabled for https support")) |
276 |
diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py |
277 |
index 11420b46c..a6f9fc833 100644 |
278 |
--- a/lib/portage/glsa.py |
279 |
+++ b/lib/portage/glsa.py |
280 |
@@ -5,10 +5,7 @@ from __future__ import absolute_import |
281 |
|
282 |
import io |
283 |
import sys |
284 |
-try: |
285 |
- from urllib.request import urlopen as urllib_request_urlopen |
286 |
-except ImportError: |
287 |
- from urllib import urlopen as urllib_request_urlopen |
288 |
+from urllib.request import urlopen as urllib_request_urlopen |
289 |
import codecs |
290 |
import re |
291 |
import operator |
292 |
diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py |
293 |
index 9682fea89..e384af868 100644 |
294 |
--- a/lib/portage/package/ebuild/fetch.py |
295 |
+++ b/lib/portage/package/ebuild/fetch.py |
296 |
@@ -20,16 +20,8 @@ import tempfile |
297 |
import time |
298 |
|
299 |
from collections import OrderedDict |
300 |
- |
301 |
-try: |
302 |
- from urllib.parse import urlparse |
303 |
-except ImportError: |
304 |
- from urlparse import urlparse |
305 |
- |
306 |
-try: |
307 |
- from urllib.parse import quote as urlquote |
308 |
-except ImportError: |
309 |
- from urllib import quote as urlquote |
310 |
+from urllib.parse import urlparse |
311 |
+from urllib.parse import quote as urlquote |
312 |
|
313 |
import portage |
314 |
portage.proxy.lazyimport.lazyimport(globals(), |
315 |
diff --git a/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py b/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py |
316 |
index d3cd94b35..900bb5115 100644 |
317 |
--- a/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py |
318 |
+++ b/lib/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py |
319 |
@@ -1,10 +1,7 @@ |
320 |
# Copyright 2018 Gentoo Foundation |
321 |
# Distributed under the terms of the GNU General Public License v2 |
322 |
|
323 |
-try: |
324 |
- import asyncio |
325 |
-except ImportError: |
326 |
- asyncio = None |
327 |
+import asyncio |
328 |
|
329 |
from portage.tests import TestCase |
330 |
from portage.util.futures.unix_events import DefaultEventLoopPolicy |
331 |
@@ -12,9 +9,6 @@ from portage.util.futures.unix_events import DefaultEventLoopPolicy |
332 |
|
333 |
class PolicyWrapperRecursionTestCase(TestCase): |
334 |
def testPolicyWrapperRecursion(self): |
335 |
- if asyncio is None: |
336 |
- self.skipTest('asyncio is not available') |
337 |
- |
338 |
initial_policy = asyncio.get_event_loop_policy() |
339 |
if not isinstance(initial_policy, DefaultEventLoopPolicy): |
340 |
asyncio.set_event_loop_policy(DefaultEventLoopPolicy()) |
341 |
diff --git a/lib/portage/tests/util/futures/test_retry.py b/lib/portage/tests/util/futures/test_retry.py |
342 |
index 94ede2e17..68c9969ac 100644 |
343 |
--- a/lib/portage/tests/util/futures/test_retry.py |
344 |
+++ b/lib/portage/tests/util/futures/test_retry.py |
345 |
@@ -1,10 +1,7 @@ |
346 |
# Copyright 2018-2020 Gentoo Authors |
347 |
# Distributed under the terms of the GNU General Public License v2 |
348 |
|
349 |
-try: |
350 |
- from concurrent.futures import ThreadPoolExecutor |
351 |
-except ImportError: |
352 |
- ThreadPoolExecutor = None |
353 |
+from concurrent.futures import ThreadPoolExecutor |
354 |
|
355 |
try: |
356 |
import threading |
357 |
diff --git a/lib/portage/tests/util/test_socks5.py b/lib/portage/tests/util/test_socks5.py |
358 |
index f7b893996..e567006ea 100644 |
359 |
--- a/lib/portage/tests/util/test_socks5.py |
360 |
+++ b/lib/portage/tests/util/test_socks5.py |
361 |
@@ -16,15 +16,8 @@ from portage.util._eventloop.global_event_loop import global_event_loop |
362 |
from portage.util import socks5 |
363 |
from portage.const import PORTAGE_BIN_PATH |
364 |
|
365 |
-try: |
366 |
- from http.server import BaseHTTPRequestHandler, HTTPServer |
367 |
-except ImportError: |
368 |
- from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer |
369 |
- |
370 |
-try: |
371 |
- from urllib.request import urlopen |
372 |
-except ImportError: |
373 |
- from urllib import urlopen |
374 |
+from http.server import BaseHTTPRequestHandler, HTTPServer |
375 |
+from urllib.request import urlopen |
376 |
|
377 |
|
378 |
class _Handler(BaseHTTPRequestHandler): |
379 |
diff --git a/lib/portage/tests/util/test_xattr.py b/lib/portage/tests/util/test_xattr.py |
380 |
index 2e2564a6e..8e8c2a3d6 100644 |
381 |
--- a/lib/portage/tests/util/test_xattr.py |
382 |
+++ b/lib/portage/tests/util/test_xattr.py |
383 |
@@ -5,16 +5,7 @@ |
384 |
|
385 |
from __future__ import print_function |
386 |
|
387 |
-try: |
388 |
- # Try python-3.3 module first. |
389 |
- # pylint: disable=no-name-in-module |
390 |
- from unittest import mock |
391 |
-except ImportError: |
392 |
- try: |
393 |
- # Try standalone module. |
394 |
- import mock |
395 |
- except ImportError: |
396 |
- mock = None |
397 |
+from unittest import mock |
398 |
|
399 |
import subprocess |
400 |
|
401 |
@@ -50,9 +41,6 @@ class SystemCommandsTest(TestCase): |
402 |
)) |
403 |
|
404 |
def _setUp(self): |
405 |
- if mock is None: |
406 |
- self.skipTest('need mock for testing') |
407 |
- |
408 |
return _XattrSystemCommands |
409 |
|
410 |
def _testGetBasic(self): |
411 |
diff --git a/lib/portage/util/__init__.py b/lib/portage/util/__init__.py |
412 |
index e390874f2..59f1518d6 100644 |
413 |
--- a/lib/portage/util/__init__.py |
414 |
+++ b/lib/portage/util/__init__.py |
415 |
@@ -14,10 +14,7 @@ __all__ = ['apply_permissions', 'apply_recursive_permissions', |
416 |
from copy import deepcopy |
417 |
import errno |
418 |
import io |
419 |
-try: |
420 |
- from itertools import chain, filterfalse |
421 |
-except ImportError: |
422 |
- from itertools import chain, ifilterfalse as filterfalse |
423 |
+from itertools import chain, filterfalse |
424 |
import logging |
425 |
import re |
426 |
import shlex |
427 |
diff --git a/lib/portage/util/_dyn_libs/PreservedLibsRegistry.py b/lib/portage/util/_dyn_libs/PreservedLibsRegistry.py |
428 |
index cb38c513c..ec8fdff5d 100644 |
429 |
--- a/lib/portage/util/_dyn_libs/PreservedLibsRegistry.py |
430 |
+++ b/lib/portage/util/_dyn_libs/PreservedLibsRegistry.py |
431 |
@@ -4,14 +4,10 @@ |
432 |
import errno |
433 |
import json |
434 |
import logging |
435 |
+import pickle |
436 |
import stat |
437 |
import sys |
438 |
|
439 |
-try: |
440 |
- import cPickle as pickle |
441 |
-except ImportError: |
442 |
- import pickle |
443 |
- |
444 |
from portage import abssymlink |
445 |
from portage import os |
446 |
from portage import _encodings |
447 |
diff --git a/lib/portage/util/_eventloop/EventLoop.py b/lib/portage/util/_eventloop/EventLoop.py |
448 |
index f870190d9..7dcc7a231 100644 |
449 |
--- a/lib/portage/util/_eventloop/EventLoop.py |
450 |
+++ b/lib/portage/util/_eventloop/EventLoop.py |
451 |
@@ -14,10 +14,7 @@ import sys |
452 |
import time |
453 |
import traceback |
454 |
|
455 |
-try: |
456 |
- import asyncio as _real_asyncio |
457 |
-except ImportError: |
458 |
- _real_asyncio = None |
459 |
+import asyncio as _real_asyncio |
460 |
|
461 |
try: |
462 |
import fcntl |
463 |
@@ -962,9 +959,8 @@ class EventLoop(object): |
464 |
executor = ForkExecutor(loop=self) |
465 |
self._default_executor = executor |
466 |
future = executor.submit(func, *args) |
467 |
- if _real_asyncio is not None: |
468 |
- future = _real_asyncio.wrap_future(future, |
469 |
- loop=self._asyncio_wrapper) |
470 |
+ future = _real_asyncio.wrap_future(future, |
471 |
+ loop=self._asyncio_wrapper) |
472 |
return future |
473 |
|
474 |
def is_running(self): |
475 |
diff --git a/lib/portage/util/_eventloop/asyncio_event_loop.py b/lib/portage/util/_eventloop/asyncio_event_loop.py |
476 |
index ce7e06923..605e7243b 100644 |
477 |
--- a/lib/portage/util/_eventloop/asyncio_event_loop.py |
478 |
+++ b/lib/portage/util/_eventloop/asyncio_event_loop.py |
479 |
@@ -4,13 +4,8 @@ |
480 |
import os |
481 |
import signal |
482 |
|
483 |
-try: |
484 |
- import asyncio as _real_asyncio |
485 |
- from asyncio.events import AbstractEventLoop as _AbstractEventLoop |
486 |
-except ImportError: |
487 |
- # Allow ImportModulesTestCase to succeed. |
488 |
- _real_asyncio = None |
489 |
- _AbstractEventLoop = object |
490 |
+import asyncio as _real_asyncio |
491 |
+from asyncio.events import AbstractEventLoop as _AbstractEventLoop |
492 |
|
493 |
import portage |
494 |
|
495 |
diff --git a/lib/portage/util/_urlopen.py b/lib/portage/util/_urlopen.py |
496 |
index c74fb2691..de0363533 100644 |
497 |
--- a/lib/portage/util/_urlopen.py |
498 |
+++ b/lib/portage/util/_urlopen.py |
499 |
@@ -6,15 +6,9 @@ import sys |
500 |
from datetime import datetime |
501 |
from time import mktime |
502 |
from email.utils import formatdate, parsedate |
503 |
- |
504 |
-try: |
505 |
- from urllib.request import urlopen as _urlopen |
506 |
- import urllib.parse as urllib_parse |
507 |
- import urllib.request as urllib_request |
508 |
-except ImportError: |
509 |
- from urllib import urlopen as _urlopen |
510 |
- import urlparse as urllib_parse |
511 |
- import urllib2 as urllib_request |
512 |
+from urllib.request import urlopen as _urlopen |
513 |
+import urllib.parse as urllib_parse |
514 |
+import urllib.request as urllib_request |
515 |
|
516 |
|
517 |
# to account for the difference between TIMESTAMP of the index' contents |
518 |
diff --git a/lib/portage/util/futures/_asyncio/__init__.py b/lib/portage/util/futures/_asyncio/__init__.py |
519 |
index 04034911d..73f4881be 100644 |
520 |
--- a/lib/portage/util/futures/_asyncio/__init__.py |
521 |
+++ b/lib/portage/util/futures/_asyncio/__init__.py |
522 |
@@ -23,10 +23,7 @@ __all__ = ( |
523 |
import subprocess |
524 |
import sys |
525 |
|
526 |
-try: |
527 |
- import asyncio as _real_asyncio |
528 |
-except ImportError: |
529 |
- _real_asyncio = None |
530 |
+import asyncio as _real_asyncio |
531 |
|
532 |
try: |
533 |
import threading |
534 |
@@ -159,7 +156,7 @@ def iscoroutinefunction(func): |
535 |
""" |
536 |
if _compat_coroutine._iscoroutinefunction(func): |
537 |
return True |
538 |
- elif _real_asyncio is not None and _real_asyncio.iscoroutinefunction(func): |
539 |
+ elif _real_asyncio.iscoroutinefunction(func): |
540 |
return True |
541 |
return False |
542 |
|
543 |
diff --git a/lib/portage/util/futures/_asyncio/tasks.py b/lib/portage/util/futures/_asyncio/tasks.py |
544 |
index b20765b7a..6d4e16223 100644 |
545 |
--- a/lib/portage/util/futures/_asyncio/tasks.py |
546 |
+++ b/lib/portage/util/futures/_asyncio/tasks.py |
547 |
@@ -8,12 +8,7 @@ ___all___ = ( |
548 |
'wait', |
549 |
) |
550 |
|
551 |
-try: |
552 |
- from asyncio import ALL_COMPLETED, FIRST_COMPLETED, FIRST_EXCEPTION |
553 |
-except ImportError: |
554 |
- ALL_COMPLETED = 'ALL_COMPLETED' |
555 |
- FIRST_COMPLETED ='FIRST_COMPLETED' |
556 |
- FIRST_EXCEPTION = 'FIRST_EXCEPTION' |
557 |
+from asyncio import ALL_COMPLETED, FIRST_COMPLETED, FIRST_EXCEPTION |
558 |
|
559 |
import portage |
560 |
portage.proxy.lazyimport.lazyimport(globals(), |
561 |
diff --git a/lib/portage/util/futures/events.py b/lib/portage/util/futures/events.py |
562 |
index b772bc242..fb1585b32 100644 |
563 |
--- a/lib/portage/util/futures/events.py |
564 |
+++ b/lib/portage/util/futures/events.py |
565 |
@@ -9,14 +9,10 @@ __all__ = ( |
566 |
import socket |
567 |
import subprocess |
568 |
|
569 |
-try: |
570 |
- from asyncio.events import ( |
571 |
- AbstractEventLoop as _AbstractEventLoop, |
572 |
- AbstractEventLoopPolicy as _AbstractEventLoopPolicy, |
573 |
- ) |
574 |
-except ImportError: |
575 |
- _AbstractEventLoop = object |
576 |
- _AbstractEventLoopPolicy = object |
577 |
+from asyncio.events import ( |
578 |
+ AbstractEventLoop as _AbstractEventLoop, |
579 |
+ AbstractEventLoopPolicy as _AbstractEventLoopPolicy, |
580 |
+) |
581 |
|
582 |
|
583 |
class AbstractEventLoopPolicy(_AbstractEventLoopPolicy): |
584 |
diff --git a/lib/portage/util/futures/futures.py b/lib/portage/util/futures/futures.py |
585 |
index dffb9e47f..5a88f121e 100644 |
586 |
--- a/lib/portage/util/futures/futures.py |
587 |
+++ b/lib/portage/util/futures/futures.py |
588 |
@@ -12,32 +12,12 @@ __all__ = ( |
589 |
'TimeoutError', |
590 |
) |
591 |
|
592 |
-try: |
593 |
- from asyncio import ( |
594 |
- CancelledError, |
595 |
- Future, |
596 |
- InvalidStateError, |
597 |
- TimeoutError, |
598 |
- ) |
599 |
-except ImportError: |
600 |
- |
601 |
- from portage.exception import PortageException |
602 |
- |
603 |
- class Error(PortageException): |
604 |
- pass |
605 |
- |
606 |
- class CancelledError(Error): |
607 |
- def __init__(self): |
608 |
- Error.__init__(self, "cancelled") |
609 |
- |
610 |
- class TimeoutError(Error): |
611 |
- def __init__(self): |
612 |
- Error.__init__(self, "timed out") |
613 |
- |
614 |
- class InvalidStateError(Error): |
615 |
- pass |
616 |
- |
617 |
- Future = None |
618 |
+from asyncio import ( |
619 |
+ CancelledError, |
620 |
+ Future, |
621 |
+ InvalidStateError, |
622 |
+ TimeoutError, |
623 |
+) |
624 |
|
625 |
import portage |
626 |
portage.proxy.lazyimport.lazyimport(globals(), |
627 |
@@ -191,7 +171,3 @@ class _EventLoopFuture(object): |
628 |
self._exception = exception |
629 |
self._state = _FINISHED |
630 |
self._schedule_callbacks() |
631 |
- |
632 |
- |
633 |
-if Future is None: |
634 |
- Future = _EventLoopFuture |
635 |
diff --git a/lib/portage/util/futures/transports.py b/lib/portage/util/futures/transports.py |
636 |
index 60ea93073..016ecbef8 100644 |
637 |
--- a/lib/portage/util/futures/transports.py |
638 |
+++ b/lib/portage/util/futures/transports.py |
639 |
@@ -1,10 +1,7 @@ |
640 |
# Copyright 2018 Gentoo Foundation |
641 |
# Distributed under the terms of the GNU General Public License v2 |
642 |
|
643 |
-try: |
644 |
- from asyncio.transports import Transport as _Transport |
645 |
-except ImportError: |
646 |
- _Transport = object |
647 |
+from asyncio.transports import Transport as _Transport |
648 |
|
649 |
|
650 |
class _FlowControlMixin(_Transport): |
651 |
diff --git a/lib/portage/util/futures/unix_events.py b/lib/portage/util/futures/unix_events.py |
652 |
index 4adf021ce..6cd0848f7 100644 |
653 |
--- a/lib/portage/util/futures/unix_events.py |
654 |
+++ b/lib/portage/util/futures/unix_events.py |
655 |
@@ -6,20 +6,13 @@ __all__ = ( |
656 |
'DefaultEventLoopPolicy', |
657 |
) |
658 |
|
659 |
-try: |
660 |
- import asyncio as _real_asyncio |
661 |
- from asyncio.base_subprocess import BaseSubprocessTransport as _BaseSubprocessTransport |
662 |
- from asyncio.unix_events import AbstractChildWatcher as _AbstractChildWatcher |
663 |
- from asyncio.transports import ( |
664 |
- ReadTransport as _ReadTransport, |
665 |
- WriteTransport as _WriteTransport, |
666 |
- ) |
667 |
-except ImportError: |
668 |
- _real_asyncio = None |
669 |
- _AbstractChildWatcher = object |
670 |
- _BaseSubprocessTransport = object |
671 |
- _ReadTransport = object |
672 |
- _WriteTransport = object |
673 |
+import asyncio as _real_asyncio |
674 |
+from asyncio.base_subprocess import BaseSubprocessTransport as _BaseSubprocessTransport |
675 |
+from asyncio.unix_events import AbstractChildWatcher as _AbstractChildWatcher |
676 |
+from asyncio.transports import ( |
677 |
+ ReadTransport as _ReadTransport, |
678 |
+ WriteTransport as _WriteTransport, |
679 |
+) |
680 |
|
681 |
import errno |
682 |
import fcntl |
683 |
-- |
684 |
2.27.0 |