Skip to content

Documented equivalent of gzip -n (omit timestamp and original file name) in gzip module #82906

Closed as duplicate

Description

@zwol
mannequin
BPO 38725

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 2019-11-06.20:06:31.047>
labels = ['library']
title = 'Documented equivalent of `gzip -n` (omit timestamp and original file name) in gzip module'
updated_at = <Date 2019-11-06.20:06:31.047>
user = 'https://bugs.python.org/zwol'

bugs.python.org fields:

activity = <Date 2019-11-06.20:06:31.047>
actor = 'zwol'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2019-11-06.20:06:31.047>
creator = 'zwol'
dependencies = []
files = []
hgrepos = []
issue_num = 38725
keywords = []
message_count = 1.0
messages = ['356150']
nosy_count = 1.0
nosy_names = ['zwol']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue38725'
versions = []

Activity

  1. zwol commented on Nov 6, 2019

    zwolmannequin
    MannequinAuthor

    Recent versions of the gzip command-line utility have an option -n which causes it to omit the FNAME field of the gzip file header, and write out the MTIME field as zero. Both of these properties are desirable when constructing reproducible build artifacts (see https://reproducible-builds.org/ ).

    Right now, the gzip module lets you set MTIME to zero explicitly by passing mtime=0 to the GzipFile constructor, but this is not documented. You can avoid writing out a filename by opening the output file yourself:

    with gzip.GzipFile(fileobj=open("foo.gz", "wb"),
                       filename='', mtime=0) as ofp:
        ... write to ofp ...
    

    but that's awkward and, again, not documented. I'd like to be able to write something like this instead:

        with gzip.open("foo.gz", mtime=0, record_filename=False) as ofp:

    with this being the documented way to achieve the same effect as gzip -n.

  2. added
    stdlib
    on Nov 6, 2019
  3. transferred this issue fromon Apr 10, 2022
  4. added
    type-feature
    docs
    on May 21, 2026
  5. serhiy-storchaka commented on May 21, 2026

    @serhiy-storchaka
    Member

    This was documented in bpo-43848/#88014.

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

    docsstdlibtype-feature

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions