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

Skip to content

Commit 6fcab4d

Browse files
anntzerMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #10867: MNT: move bz2 back to function level
1 parent 94c63af commit 6fcab4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import six
1212
from six.moves import xrange, zip
13-
import bz2
1413
import collections
1514
import contextlib
1615
import datetime
@@ -602,6 +601,9 @@ def to_filehandle(fname, flag='rU', return_opened=False, encoding=None):
602601
flag = flag.replace('U', '')
603602
fh = gzip.open(fname, flag)
604603
elif fname.endswith('.bz2'):
604+
# python may not be complied with bz2 support,
605+
# bury import until we need it
606+
import bz2
605607
# get rid of 'U' in flag for bz2 files
606608
flag = flag.replace('U', '')
607609
fh = bz2.BZ2File(fname, flag)

0 commit comments

Comments
 (0)