]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90839: Forward gzip.compress() compresslevel to zlib (gh-31215)
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 12 Apr 2022 13:46:40 +0000 (15:46 +0200)
committerGitHub <noreply@github.com>
Tue, 12 Apr 2022 13:46:40 +0000 (22:46 +0900)
Lib/gzip.py
Misc/NEWS.d/next/Library/2022-03-21-13-50-07.bpo-46681.RRhopn.rst [new file with mode: 0644]

index 6773ea3eef0971df7aee1277346a9ebadaa8b5e3..5b20e5ba698ee996c37ad5904491b3171c3a25f5 100644 (file)
@@ -587,7 +587,8 @@ def compress(data, compresslevel=_COMPRESS_LEVEL_BEST, *, mtime=None):
     header = _create_simple_gzip_header(compresslevel, mtime)
     trailer = struct.pack("<LL", zlib.crc32(data), (len(data) & 0xffffffff))
     # Wbits=-15 creates a raw deflate block.
-    return header + zlib.compress(data, wbits=-15) + trailer
+    return (header + zlib.compress(data, level=compresslevel, wbits=-15) +
+            trailer)
 
 
 def decompress(data):
diff --git a/Misc/NEWS.d/next/Library/2022-03-21-13-50-07.bpo-46681.RRhopn.rst b/Misc/NEWS.d/next/Library/2022-03-21-13-50-07.bpo-46681.RRhopn.rst
new file mode 100644 (file)
index 0000000..7668605
--- /dev/null
@@ -0,0 +1 @@
+Forward gzip.compress() compresslevel to zlib.