summaryrefslogtreecommitdiff
path: root/numpy/lib/_datasource.py
diff options
context:
space:
mode:
authorEelcoPeacs <eelco.van.dam@peacs.nl>2019-01-16 14:37:57 +0100
committerEelcoPeacs <eelco.van.dam@peacs.nl>2019-01-16 14:37:57 +0100
commit19bc9a150fe73d5985edfe6d0b06285c23fcfc01 (patch)
tree31bd55e30f6f81cf781298af6dea57ed93947926 /numpy/lib/_datasource.py
parent49689f7be478fe9a4d33761b080eb6aef3f8f899 (diff)
downloadnumpy-19bc9a150fe73d5985edfe6d0b06285c23fcfc01.tar.gz
ENH: Changed the sequence of checking for locale existence of a file and importing urllib modules in numpy._datasource.py to prevent the import in case the local file was found
See #12536
Diffstat (limited to 'numpy/lib/_datasource.py')
-rw-r--r--numpy/lib/_datasource.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py
index 3a0e67f60..816f7624e 100644
--- a/numpy/lib/_datasource.py
+++ b/numpy/lib/_datasource.py
@@ -547,6 +547,11 @@ class DataSource(object):
is accessible if it exists in either location.
"""
+
+ # First test for local path
+ if os.path.exists(path):
+ return True
+
# We import this here because importing urllib2 is slow and
# a significant fraction of numpy's total import time.
if sys.version_info[0] >= 3:
@@ -556,10 +561,6 @@ class DataSource(object):
from urllib2 import urlopen
from urllib2 import URLError
- # Test local path
- if os.path.exists(path):
- return True
-
# Test cached url
upath = self.abspath(path)
if os.path.exists(upath):