This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: gzip.compress does not forward compresslevel to zlib.compress
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: iii-i, lukasz.langa
Priority: normal Keywords: patch

Created on 2022-02-08 14:52 by iii-i, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 31215 open iii-i, 2022-02-08 15:16
Messages (1)
msg412843 - (view) Author: Ilya Leoshkevich (iii-i) * Date: 2022-02-08 14:52
Started with:

commit ea23e7820f02840368569db8082bd0ca4d59b62a
Author: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date:   Thu Sep 2 17:02:59 2021 +0200

    bpo-43613: Faster implementation of gzip.compress and gzip.decompress (GH-27941)
    
    Co-authored-by: Łukasz Langa <lukasz@langa.pl>

The fix is quite trivial:

--- 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)

I'll send a PR.
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90839
2022-02-10 14:03:20xtreaksetnosy: + lukasz.langa
2022-02-08 15:16:28iii-isetkeywords: + patch
stage: patch review
pull_requests: + pull_request29385
2022-02-08 14:52:52iii-icreate