55import codecs
66import mmap
77from contextlib import contextmanager , closing
8- from zipfile import ZipFile
8+ import zipfile
99
1010from pandas .compat import StringIO , BytesIO , string_types , text_type
1111from pandas import compat
@@ -428,7 +428,7 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
428428 return f , handles
429429
430430
431- class BytesZipFile (ZipFile , BytesIO ):
431+ class BytesZipFile (zipfile . ZipFile , BytesIO ):
432432 """
433433 Wrapper for standard library class ZipFile and allow the returned file-like
434434 handle to accept byte strings via `write` method.
@@ -437,10 +437,8 @@ class BytesZipFile(ZipFile, BytesIO):
437437 bytes strings into a member of the archive.
438438 """
439439 # GH 17778
440- def __init__ (self , file , mode = 'r' , ** kwargs ):
441- if mode in ['wb' , 'rb' ]:
442- mode = mode .replace ('b' , '' )
443- super (BytesZipFile , self ).__init__ (file , mode , ** kwargs )
440+ def __init__ (self , file , mode , compression = zipfile .ZIP_DEFLATED , ** kwargs ):
441+ super (BytesZipFile , self ).__init__ (file , mode , compression , ** kwargs )
444442
445443 def write (self , data ):
446444 super (BytesZipFile , self ).writestr (self .filename , data )
0 commit comments