Skip to content

Commit 51c79c8

Browse files
authored
Merge pull request #10867 from tacaswell/fix_hide_bz2
MNT: move bz2 back to function level
2 parents 7a3248f + ffe9203 commit 51c79c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/cbook/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import six
1010
from six.moves import xrange, zip
11-
import bz2
1211
import collections
1312
import contextlib
1413
import datetime
@@ -478,6 +477,9 @@ def to_filehandle(fname, flag='rU', return_opened=False, encoding=None):
478477
flag = flag.replace('U', '')
479478
fh = gzip.open(fname, flag)
480479
elif fname.endswith('.bz2'):
480+
# python may not be complied with bz2 support,
481+
# bury import until we need it
482+
import bz2
481483
# get rid of 'U' in flag for bz2 files
482484
flag = flag.replace('U', '')
483485
fh = bz2.BZ2File(fname, flag)

0 commit comments

Comments
 (0)