[issue46681] gzip.compress does not forward compresslevel to zlib.compress
Ilya Leoshkevich
report at bugs.python.org
Tue Feb 8 09:52:52 EST 2022
New submission from Ilya Leoshkevich <iii at linux.ibm.com>:
Started with:
commit ea23e7820f02840368569db8082bd0ca4d59b62a
Author: Ruben Vorderman <r.h.p.vorderman at 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 at 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.
----------
components: Library (Lib)
messages: 412843
nosy: iii-i
priority: normal
severity: normal
status: open
title: gzip.compress does not forward compresslevel to zlib.compress
type: behavior
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46681>
_______________________________________
More information about the Python-bugs-list
mailing list