summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-01-17 16:32:31 -0700
committerGitHub <noreply@github.com>2019-01-17 16:32:31 -0700
commit4e724834fae348af564e38e6528ce2dab131e61a (patch)
treef8fb872251c7a2da016a412cc4e15b175784b395
parentfd6d2bc4f6d8424fbe1b3e1219530496affc57fd (diff)
parent19bc9a150fe73d5985edfe6d0b06285c23fcfc01 (diff)
downloadnumpy-4e724834fae348af564e38e6528ce2dab131e61a.tar.gz
Merge pull request #12762 from EelcoPeacs/local_datasource_first
MAINT: Change the order of checking for locale file and import urllib modules
-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):