8000 Merge branch 'master' of github.com:matplotlib/matplotlib · gregglind/matplotlib@15b0e60 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15b0e60

Browse files
committed
Merge branch 'master' of github.com:matplotlib/matplotlib
2 parents dfc66d5 + 41e09f7 commit 15b0e60

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

lib/matplotlib/cbook.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,29 @@
1919

2020
major, minor1, minor2, s, tmp = sys.version_info
2121

22+
# Handle the transition from urllib2 in Python 2 to urllib in Python 3
2223
if major >= 3:
2324
import types
24-
import urllib.request
25+
import urllib.request, urllib.error, urllib.parse
26+
def urllib_quote():
27+
return urllib.parse.quote
2528
def addinfourl(data, headers, url, code=None):
2629
return urllib.request.addinfourl(io.BytesIO(data),
2730
headers, url, code)
31+
urllib_HTTPSHandler = urllib.request.HTTPSHandler
32+
urllib_build_opener = urllib.request.build_opener
33+
urllib_URLError = urllib.error.URLError
2834
else:
2935
import new
3036
import urllib2
37+
def urllib_quote():
38+
return urllib2.quote
3139
def addinfourl(data, headers, url, code=None):
3240
return urllib2.addinfourl(io.StringIO(data),
3341
headers, url, code)
42+
urllib_HTTPSHandler = urllib2.HTTPSHandler
43+
urllib_build_opener = urllib2.build_opener
44+
urllib_URLError = urllib2.URLError
3445

3546
# On some systems, locale.getpreferredencoding returns None,
3647
# which can break unicode; and the sage project reports that
@@ -481,19 +492,18 @@ def is_scalar_or_string(val):
481492
return is_string_like(val) or not iterable(val)
482493

483494
def _get_data_server(cache_dir, baseurl):
484-
import urllib2
485-
class ViewVCCachedServer(urllib2.HTTPSHandler):
495+
class ViewVCCachedServer(urllib_HTTPSHandler):
486496
"""
487-
Urllib2 handler that takes care of caching files.
497+
Urllib handler that takes care of caching files.
488498
The file cache.pck holds the directory of files that have been cached.
489499
"""
490500
def __init__(self, cache_dir, baseurl):
491-
urllib2.HTTPSHandler.__init__(self)
501+
urllib_HTTPSHandler.__init__(self)
492502
self.cache_dir = cache_dir
493503
self.baseurl = baseurl
494504
self.read_cache()
495505
self.remove_stale_files()
496-
self.opener = urllib2.build_opener(self)
506+
self.opener = urllib_build_opener(self)
497507

498508
def in_cache_dir(self, fn):
499509
# make sure the datadir exists
@@ -576,7 +586,7 @@ def cache_file(self, url, data, headers):
576586
headers.get('Last-Modified'))
577587
self.write_cache()
578588

579-
# These urllib2 entry points are used:
589+
# These urllib entry points are used:
580590
# http_request for preprocessing requests
581591
# http_error_304 for handling 304 Not Modified responses
582592
# http_response for postprocessing requests
@@ -607,7 +617,7 @@ def https_error_304(self, req, fp, code, msg, hdrs):
607617
'ViewVCCachedServer: reading data file from cache file "%s"'
608618
%fn, 'debug')
609619
with open(fn, 'rb') as file:
610-
handle = urllib2.addinfourl(file, hdrs, url)
620+
handle = addinfourl(file, hdrs, url)
611621
handle.code = 304
612622
return handle
613623

@@ -623,9 +633,9 @@ def https_response(self, req, response):
623633
else:
624634
data = response.read()
625635
self.cache_file(req.get_full_url(), data, response.headers)
626-
result = urllib2.addinfourl(StringIO.StringIO(data),
627-
response.headers,
628-
req.get_full_url())
636+
result = addinfourl(StringIO.StringIO(data),
637+
response.headers,
638+
req.get_full_url())
629639
result.code = response.code
630640
result.msg = response.msg
631641
return result
@@ -640,14 +650,9 @@ def get_sample_data(self, fname, asfileobj=True):
640650
path to the file as a string will be returned.
641651
"""
642652
# TODO: time out if the connection takes forever
643-
# (may not be possible with urllib2 only - spawn a helper process?)
653+
# (may not be possible with urllib only - spawn a helper process?)
644654

645-
# quote is not in python2.4, so check for it and get it from
646-
# urllib if it is not available
647-
quote = getattr(urllib2, 'quote', None)
648-
if quote is None:
649-
import urllib
650-
quote = urllib.quote
655+
quote = urllib_quote()
651656

652657
# retrieve the URL for the side effect of refreshing the cache
653658
url = self.baseurl + quote(fname)
@@ -656,7 +661,7 @@ def get_sample_data(self, fname, asfileobj=True):
656661
% url, 'debug')
657662
try:
658663
response = self.opener 9D65 .open(url)
659-
except urllib2.URLError, e:
664+
except urllib_URLError as e:
660665
# could be a missing network connection
661666
error = str(e)
662667

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def init3d(self):
102102

103103
# Store dummy data in Polygon object
104104
self.pane = mpatches.Polygon(np.array([[0,0], [0,1], [1,0], [0,0]]),
105+
closed=False,
105106
alpha=0.8,
106107
facecolor=(1,1,1,0),
107108
edgecolor=(1,1,1,0))

0 commit comments

Comments
 (0)
0