Skip to content

Commit 025c03b

Browse files
committed
In gzip.rst, extend explanation of argument mtime, and simplify description of attribute mtime
1 parent c43cb2a commit 025c03b

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Doc/library/gzip.rst

+10-14
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ The module defines the following items:
100100
compression, and ``9`` is slowest and produces the most compression. ``0``
101101
is no compression. The default is ``9``.
102102

103-
The *mtime* argument is an optional numeric timestamp to be written to
104-
the last modification time field in the stream when compressing. It
105-
should only be provided in compression mode. If omitted or ``None``, the
106-
current time is used. See the :attr:`mtime` attribute for more details.
103+
The optional *mtime* argument is the timestamp requested by gzip. The time
104+
is in Unix format, i.e., seconds since 00:00:00 GMT, Jan. 1, 1970.
105+
If mtime is omitted or None, the current time is used. Use mtime = 0
106+
to generate a compressed stream that does not depend on creation time.
107+
108+
See below for the :attr:`mtime` attribute that is set when decompressing.
107109

108110
Calling a :class:`GzipFile` object's :meth:`close` method does not close
109111
*fileobj*, since you might wish to append more material after the compressed
@@ -133,15 +135,10 @@ The module defines the following items:
133135

134136
.. attribute:: mtime
135137

136-
When decompressing, the value of the last modification time field in
137-
the most recently read header may be read from this attribute, as an
138-
integer. The initial value before reading any headers is ``None``.
139-
140-
All :program:`gzip` compressed streams are required to contain this
141-
timestamp field. Some programs, such as :program:`gunzip`\ , make use
142-
of the timestamp. The format is the same as the return value of
143-
:func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of
144-
the object returned by :func:`os.stat`.
138+
When decompressing, this attribute is set to last timestamp in the most
139+
recently read header. It is an integer, holding the number of seconds
140+
since the Unix epoch (00:00:00 GMT, Jan. 1, 1970).
141+
The initial value before reading any headers is ``None``.
145142

146143
.. versionchanged:: 3.1
147144
Support for the :keyword:`with` statement was added, along with the
@@ -275,4 +272,3 @@ Command line options
275272
.. cmdoption:: -h, --help
276273

277274
Show the help message.
278-

0 commit comments

Comments
 (0)