Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip.compress does not forward compresslevel to zlib.compress #90839

Closed
iii-i mannequin opened this issue Feb 8, 2022 · 1 comment
Closed

gzip.compress does not forward compresslevel to zlib.compress #90839

iii-i mannequin opened this issue Feb 8, 2022 · 1 comment
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@iii-i
Copy link
Mannequin

iii-i mannequin commented Feb 8, 2022

BPO 46681
Nosy @ambv, @iii-i
PRs
  • gh-90839: Forward gzip.compress() compresslevel to zlib #31215
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-08.14:52:52.369>
    labels = ['type-bug', 'library', '3.11']
    title = 'gzip.compress does not forward compresslevel to zlib.compress'
    updated_at = <Date 2022-02-10.14:03:20.381>
    user = 'https://github.com/iii-i'

    bugs.python.org fields:

    activity = <Date 2022-02-10.14:03:20.381>
    actor = 'xtreak'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-02-08.14:52:52.369>
    creator = 'iii-i'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46681
    keywords = ['patch']
    message_count = 1.0
    messages = ['412843']
    nosy_count = 2.0
    nosy_names = ['lukasz.langa', 'iii-i']
    pr_nums = ['31215']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46681'
    versions = ['Python 3.11']

    @iii-i
    Copy link
    Mannequin Author

    iii-i mannequin commented Feb 8, 2022

    Started with:

    commit ea23e78
    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.

    @iii-i iii-i mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 8, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant