New submission from Zack Weinberg <>:

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

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"foo.gz", mtime=0, record_filename=False) as ofp:

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

components: Library (Lib)
messages: 356150
nosy: zwol
priority: normal
severity: normal
status: open
title: Documented equivalent of `gzip -n` (omit timestamp and original file 
name) in gzip module

Python tracker <>
Python-bugs-list mailing list

Reply via email to