3838
3939__all__  =  ["BadZipFile" , "BadZipfile" , "error" ,
4040           "ZIP_STORED" , "ZIP_DEFLATED" , "ZIP_BZIP2" , "ZIP_LZMA" ,
41-            "is_zipfile " , "ZipInfo " , "ZipFile " , "PyZipFile " , "LargeZipFile " ,
42-            "Path" ]
41+            "ZIP_ZSTANDARD " , "is_zipfile " , "ZipInfo " , "ZipFile " , "PyZipFile " ,
42+            "LargeZipFile"  ,  " Path"
4343
4444class  BadZipFile (Exception ):
4545    pass 
@@ -812,11 +812,11 @@ def _get_compressor(compress_type, compresslevel=None):
812812        if  compresslevel  is  not None :
813813            return  bz2 .BZ2Compressor (compresslevel )
814814        return  bz2 .BZ2Compressor ()
815-     # compresslevel is ignored for ZIP_LZMA and ZIP_ZSTANDARD  
815+     # compresslevel is ignored for ZIP_LZMA 
816816    elif  compress_type  ==  ZIP_LZMA :
817817        return  LZMACompressor ()
818818    elif  compress_type  ==  ZIP_ZSTANDARD :
819-         return  zstd .ZstdCompressor ()
819+         return  zstd .ZstdCompressor (level = compresslevel )
820820    else :
821821        return  None 
822822
@@ -1352,7 +1352,8 @@ class ZipFile:
13521352    mode: The mode can be either read 'r', write 'w', exclusive create 'x', 
13531353          or append 'a'. 
13541354    compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib), 
1355-                  ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma). 
1355+                  ZIP_BZIP2 (requires bz2), ZIP_LZMA (requires lzma), or 
1356+                  ZIP_ZSTANDARD (requires compression.zstd). 
13561357    allowZip64: if True ZipFile will create files with ZIP64 extensions when 
13571358                needed, otherwise it will raise an exception when this would 
13581359                be necessary. 
@@ -1361,6 +1362,9 @@ class ZipFile:
13611362                   When using ZIP_STORED or ZIP_LZMA this keyword has no effect. 
13621363                   When using ZIP_DEFLATED integers 0 through 9 are accepted. 
13631364                   When using ZIP_BZIP2 integers 1 through 9 are accepted. 
1365+                    When using ZIP_ZSTANDARD integers -7 though 22 are common, 
1366+                    see the CompressionParameter enum in compression.zstd for 
1367+                    details. 
13641368
13651369    """ 
13661370
@@ -2093,6 +2097,8 @@ def _write_end_record(self):
20932097                min_version  =  max (BZIP2_VERSION , min_version )
20942098            elif  zinfo .compress_type  ==  ZIP_LZMA :
20952099                min_version  =  max (LZMA_VERSION , min_version )
2100+             elif  zinfo .compress_type  ==  ZIP_ZSTANDARD :
2101+                 min_version  =  max (ZSTANDARD_VERSION , min_version )
20962102
20972103            extract_version  =  max (min_version , zinfo .extract_version )
20982104            create_version  =  max (min_version , zinfo .create_version )
0 commit comments