Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 689f53b

Browse files
committed
cbook.get_sample_data raises a meaningful error
1 parent 2e443ff commit 689f53b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/cbook.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def to_filehandle(fname, flag='rU', return_opened=False):
447447
def is_scalar_or_string(val):
448448
return is_string_like(val) or not iterable(val)
449449

450-
def get_data_server(cache_dir, baseurl):
450+
def _get_data_server(cache_dir, baseurl):
451451
import urllib2
452452
class ViewVCCachedServer(urllib2.HTTPSHandler):
453453
"""
@@ -683,7 +683,13 @@ def get_sample_data(fname, asfileobj=True):
683683
configdir = matplotlib.get_configdir()
684684
cachedir = os.path.join(configdir, 'sample_data')
685685
baseurl = 'https://github.com/matplotlib/sample_data/raw/master/'
686-
myserver = get_sample_data.myserver = get_data_server(cachedir, baseurl)
686+
try:
687+
myserver = _get_data_server(cachedir, baseurl)
688+
get_sample_data.myserver = myserver
689+
except ImportError:
690+
raise ImportError(
691+
'Python must be built with SSL support to fetch sample data '
692+
'from the matplotlib repository')
687693

688694
return myserver.get_sample_data(fname, asfileobj=asfileobj)
689695

0 commit comments

Comments
 (0)