summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-01-23 17:46:35 -0700
committerGitHub <noreply@github.com>2020-01-23 17:46:35 -0700
commit4c32890b3628434996824ae2056333b9a389f46c (patch)
tree93028efe7bb782b80d94454a4ae77d3bccb6c136
parentc61e667c90f7aa80c41fcfa3dd098832fbfe7139 (diff)
parent3493d1b288eba0434257bebdd72df5c8b6da2a96 (diff)
downloadnumpy-4c32890b3628434996824ae2056333b9a389f46c.tar.gz
Merge pull request #15398 from mwtoews/urllib
MAINT: Revise imports from urllib modules
-rw-r--r--numpy/lib/_datasource.py20
-rw-r--r--tools/openblas_support.py8
2 files changed, 7 insertions, 21 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py
index cb337ce83..76cc306b7 100644
--- a/numpy/lib/_datasource.py
+++ b/numpy/lib/_datasource.py
@@ -304,10 +304,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.
@@ -324,14 +321,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)
@@ -406,10 +399,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