summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorJoachim Wuttke <j.wuttke@fz-juelich.de>2024-03-28 13:43:07 (GMT)
committerGitHub <noreply@github.com>2024-03-28 13:43:07 (GMT)
commit9a388b9a64927c372d85f0eaec3de9b7320a6fb5 (patch)
treed36c4fe910992d9933237b9445291cc4d67118c9 /Doc
parent8dbfdb2957a7baade3a88661517f163ad694c39f (diff)
downloadcpython-9a388b9a64927c372d85f0eaec3de9b7320a6fb5.zip
cpython-9a388b9a64927c372d85f0eaec3de9b7320a6fb5.tar.gz
cpython-9a388b9a64927c372d85f0eaec3de9b7320a6fb5.tar.bz2
bpo-43848: explain optional argument mtime in gzip.py. (GH-25410)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/gzip.rst23
1 files changed, 10 insertions, 13 deletions
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index 79be215..044be8c 100644
--- a/Doc/library/gzip.rst
+++ b/Doc/library/gzip.rst
@@ -100,10 +100,12 @@ The module defines the following items:
compression, and ``9`` is slowest and produces the most compression. ``0``
is no compression. The default is ``9``.
- The *mtime* argument is an optional numeric timestamp to be written to
- the last modification time field in the stream when compressing. It
- should only be provided in compression mode. If omitted or ``None``, the
- current time is used. See the :attr:`mtime` attribute for more details.
+ The optional *mtime* argument is the timestamp requested by gzip. The time
+ is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.
+ If *mtime* is omitted or None, the current time is used. Use *mtime* = 0
+ to generate a compressed stream that does not depend on creation time.
+
+ See below for the :attr:`mtime` attribute that is set when decompressing.
Calling a :class:`GzipFile` object's :meth:`!close` method does not close
*fileobj*, since you might wish to append more material after the compressed
@@ -133,15 +135,10 @@ The module defines the following items:
.. attribute:: mtime
- When decompressing, the value of the last modification time field in
- the most recently read header may be read from this attribute, as an
- integer. The initial value before reading any headers is ``None``.
-
- All :program:`gzip` compressed streams are required to contain this
- timestamp field. Some programs, such as :program:`gunzip`\ , make use
- of the timestamp. The format is the same as the return value of
- :func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of
- the object returned by :func:`os.stat`.
+ When decompressing, this attribute is set to the last timestamp in the most
+ recently read header. It is an integer, holding the number of seconds
+ since the Unix epoch (00:00:00 UTC, January 1, 1970).
+ The initial value before reading any headers is ``None``.
.. attribute:: name