@@ -28,7 +28,7 @@ Note that additional file formats which can be decompressed by the
2828The module defines the following items:
2929
3030
31- .. function :: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None)
31+ .. function :: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None, *, mtime=None )
3232
3333 Open a gzip-compressed file in binary or text mode, returning a :term: `file
3434 object `.
@@ -43,9 +43,12 @@ The module defines the following items:
4343 The *compresslevel * argument is an integer from 0 to 9, as for the
4444 :class: `GzipFile ` constructor.
4545
46+ The keyword-only argument *mtime * represents a Unix timestamp.
47+
4648 For binary mode, this function is equivalent to the :class: `GzipFile `
47- constructor: ``GzipFile(filename, mode, compresslevel) ``. In this case, the
48- *encoding *, *errors * and *newline * arguments must not be provided.
49+ constructor: ``GzipFile(filename, mode, compresslevel, mtime=mtime) ``.
50+ In this case, the *encoding *, *errors * and *newline * arguments must not
51+ be provided.
4952
5053 For text mode, a :class: `GzipFile ` object is created, and wrapped in an
5154 :class: `io.TextIOWrapper ` instance with the specified encoding, error
@@ -66,6 +69,10 @@ The module defines the following items:
6669 It is the default level used by most compression tools and a better
6770 tradeoff between speed and performance.
6871
72+ .. versionchanged :: next
73+ Added keyword-only argument *mtime * which is passed to the class
74+ constructor of :class: `~gzip.GzipFile `.
75+
6976.. exception :: BadGzipFile
7077
7178 An exception raised for invalid gzip files. It inherits from :exc: `OSError `.
@@ -108,9 +115,13 @@ The module defines the following items:
108115 is no compression. The default is ``9 ``.
109116
110117 The optional *mtime * argument is the timestamp requested by gzip. The time
111- is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.
112- If *mtime * is omitted or ``None ``, the current time is used. Use *mtime * = 0
113- to generate a compressed stream that does not depend on creation time.
118+ is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. Set
119+ *mtime * to ``0 `` to generate a compressed stream that does not depend on
120+ creation time. If *mtime * is omitted or ``None ``, the current time is used;
121+ however, if the current time is outside the range 00:00:00 UTC, January 1,
122+ 1970 through 06:28:15 UTC, February 7, 2106, or explicitly passed *mtime *
123+ argument is outside the range ``0 `` to ``2**32-1 ``, then the value ``0 ``
124+ is used instead.
114125
115126 See below for the :attr: `mtime ` attribute that is set when decompressing.
116127
0 commit comments