Skip to content

Commit 4d59631

Browse files
committed
zipfile: Allow specifying a compresslevel for zstd compression
1 parent 321c098 commit 4d59631

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/zipfile/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -1362,6 +1362,7 @@ class ZipFile:
13621362
When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
13631363
When using ZIP_DEFLATED integers 0 through 9 are accepted.
13641364
When using ZIP_BZIP2 integers 1 through 9 are accepted.
1365+
When using ZIP_ZSTANDARD integers are accepted.
13651366
13661367
"""
13671368

0 commit comments

Comments
 (0)