Skip to content

gzip.compress output is non-deterministic #125260

Closed

Description

@bmwiedemann

Bug report

Bug description:

import gzip
gzip.compress(b'')

output varies by default, which breaks reproducible builds in cases such as
https://github.com/getmoto/moto/blob/fc60bd1c5f6e6184e30a6db8b65059a2855cd28e/setup.py#L28

GNU gzip (since 1.10) defaults to a zero timestamp for compressing stdin. And after year 2106, no mtime could be stored anyway.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 10, 2024
  2. added 2 commits that reference this issue on Oct 10, 2024
  3. added
    type-featureA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or error
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    on Oct 10, 2024
  4. ZeroIntensity commented on Oct 10, 2024

    @ZeroIntensity
    Member

    Per @AA-Turner, I'm marking this as a feature.

  5. added 3 commits that reference this issue on Oct 11, 2024
  6. added a commit that references this issue on Oct 12, 2024
  7. thesamesam commented on Oct 14, 2024

    @thesamesam
    Contributor

    See also #112346 for the OS field.

  8. Rogdham commented on May 10, 2025

    @Rogdham
    Contributor

    Should the same change be made in the default for mtime parameter in GzipFile.__init__? @bmwiedemann @AA-Turner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions