@@ -368,7 +368,7 @@ ZipFile Objects
368368
369369
370370.. method :: ZipFile.write(filename, arcname=None, compress_type=None, \
371- compresslevel=None)
371+ compresslevel=None, * , strict_timestamps=True )
372372
373373 Write the file named *filename * to the archive, giving it the archive name
374374 *arcname * (by default, this will be the same as *filename *, but without a drive
@@ -377,6 +377,11 @@ ZipFile Objects
377377 the new entry. Similarly, *compresslevel * will override the constructor if
378378 given.
379379 The archive must be open with mode ``'w' ``, ``'x' `` or ``'a' ``.
380+ The *strict_timestamps * argument, when set to ``False ``, allows to
381+ zip files older than 1980-01-01 at the cost of setting the
382+ timestamp to 1980-01-01.
383+ Similar behavior occurs with files newer than 2107-12-31,
384+ the timestamp is also set to the limit.
380385
381386 .. note ::
382387
@@ -400,6 +405,9 @@ ZipFile Objects
400405 a closed ZipFile will raise a :exc: `ValueError `. Previously,
401406 a :exc: `RuntimeError ` was raised.
402407
408+ .. versionadded :: 3.8
409+ The *strict_timestamps * keyword-only argument
410+
403411
404412.. method :: ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, \
405413 compresslevel=None)
@@ -540,7 +548,8 @@ information about a single member of the ZIP archive.
540548There is one classmethod to make a :class: `ZipInfo ` instance for a filesystem
541549file:
542550
543- .. classmethod :: ZipInfo.from_file(filename, arcname=None)
551+ .. classmethod :: ZipInfo.from_file(filename, arcname=None, *, \
552+ strict_timestamps=True)
544553
545554 Construct a :class: `ZipInfo ` instance for a file on the filesystem, in
546555 preparation for adding it to a zip file.
@@ -551,11 +560,20 @@ file:
551560 If *arcname * is not specified, the name will be the same as *filename *, but
552561 with any drive letter and leading path separators removed.
553562
563+ The *strict_timestamps * argument, when set to ``False ``, allows to
564+ zip files older than 1980-01-01 at the cost of setting the
565+ timestamp to 1980-01-01.
566+ Similar behavior occurs with files newer than 2107-12-31,
567+ the timestamp is also set to the limit.
568+
554569 .. versionadded :: 3.6
555570
556571 .. versionchanged :: 3.6.2
557572 The *filename * parameter accepts a :term: `path-like object `.
558573
574+ .. versionadded :: 3.8
575+ The *strict_timestamps * keyword-only argument
576+
559577
560578Instances have the following methods and attributes:
561579
0 commit comments