diff options
author | Mike Taves <mwtoews@gmail.com> | 2020-01-23 17:36:00 +1300 |
---|---|---|
committer | Mike Taves <mwtoews@gmail.com> | 2020-01-24 11:14:29 +1300 |
commit | 3493d1b288eba0434257bebdd72df5c8b6da2a96 (patch) | |
tree | 75e08046ef1c071e0ac83efbe1ce1a6f8a8be439 | |
parent | 883de8fab38766992501bf73dd6f59eb2e0b123f (diff) | |
download | numpy-3493d1b288eba0434257bebdd72df5c8b6da2a96.tar.gz |
MAINT: Revise imports from urllib modules
-rw-r--r-- | numpy/lib/_datasource.py | 20 | ||||
-rw-r--r-- | tools/openblas_support.py | 8 |
2 files changed, 7 insertions, 21 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index 139b8c0ca..b40091c9b 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -305,10 +305,7 @@ class DataSource: """Test if path is a net location. Tests the scheme and netloc.""" # We do this here to reduce the 'import numpy' initial import time. - if sys.version_info[0] >= 3: - from urllib.parse import urlparse - else: - from urlparse import urlparse + from urllib.parse import urlparse # BUG : URLs require a scheme string ('http://') to be used. # www.google.com will fail. @@ -325,14 +322,10 @@ class DataSource: Creates a copy of the file in the datasource cache. """ - # We import these here because importing urllib2 is slow and + # We import these here because importing urllib is slow and # a significant fraction of numpy's total import time. - if sys.version_info[0] >= 3: - from urllib.request import urlopen - from urllib.error import URLError - else: - from urllib2 import urlopen - from urllib2 import URLError + from urllib.request import urlopen + from urllib.error import URLError upath = self.abspath(path) @@ -407,10 +400,7 @@ class DataSource: """ # We do this here to reduce the 'import numpy' initial import time. - if sys.version_info[0] >= 3: - from urllib.parse import urlparse - else: - from urlparse import urlparse + from urllib.parse import urlparse # TODO: This should be more robust. Handles case where path includes # the destpath, but not other sub-paths. Failing case: diff --git a/tools/openblas_support.py b/tools/openblas_support.py index 3708033d3..fdae6ab76 100644 --- a/tools/openblas_support.py +++ b/tools/openblas_support.py @@ -4,14 +4,10 @@ import glob import shutil import textwrap import platform -try: - from urllib.request import urlopen - from urllib.error import HTTPError -except: - #Python2 - from urllib2 import urlopen, HTTPError from tempfile import mkstemp, gettempdir +from urllib.request import urlopen +from urllib.error import HTTPError import zipfile import tarfile |