[Python-checkins] gh-90839: Forward gzip.compress() compresslevel to zlib (gh-31215)

corona10 webhook-mailer at python.org
Tue Apr 12 09:47:08 EDT 2022


https://github.com/python/cpython/commit/943ca5e1d6b72830c530a72426cff094f155d010
commit: 943ca5e1d6b72830c530a72426cff094f155d010
branch: main
author: Ilya Leoshkevich <iii at linux.ibm.com>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-04-12T22:46:40+09:00
summary:

gh-90839: Forward gzip.compress() compresslevel to zlib (gh-31215)

files:
A Misc/NEWS.d/next/Library/2022-03-21-13-50-07.bpo-46681.RRhopn.rst
M Lib/gzip.py

diff --git a/Lib/gzip.py b/Lib/gzip.py
index 6773ea3eef097..5b20e5ba698ee 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -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
index 0000000000000..7668605698cab
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-03-21-13-50-07.bpo-46681.RRhopn.rst
@@ -0,0 +1 @@
+Forward gzip.compress() compresslevel to zlib.



More information about the Python-checkins mailing list