diff options
author | Marcel Plch <gmarcel.plch@gmail.com> | 2018-08-02 13:04:52 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-08-02 13:04:52 (GMT) |
commit | a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4 (patch) | |
tree | 252fe3c3a784a8c4e68873be4743ba703b551653 /Doc | |
parent | fc512e3e0663f7f325862fcd42aef765fd34a453 (diff) | |
download | cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.zip cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.tar.gz cpython-a2fe1e52eb94c41d9ebce1ab284180d7b1faa2a4.tar.bz2 |
bpo-34097: Add support for zipping files older than 1980-01-01 (GH-8270)
ZipFile can zip files older than 1980-01-01 and newer than 2107-12-31 using
a new strict_timestamps parameter at the cost of setting the timestamp
to the limit.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/zipfile.rst | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index c0f2a89..a2fa966 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -368,7 +368,7 @@ ZipFile Objects .. method:: ZipFile.write(filename, arcname=None, compress_type=None, \ - compresslevel=None) + compresslevel=None, *, strict_timestamps=True) Write the file named *filename* to the archive, giving it the archive name *arcname* (by default, this will be the same as *filename*, but without a drive @@ -377,6 +377,11 @@ ZipFile Objects the new entry. Similarly, *compresslevel* will override the constructor if given. The archive must be open with mode ``'w'``, ``'x'`` or ``'a'``. + The *strict_timestamps* argument, when set to ``False``, allows to + zip files older than 1980-01-01 at the cost of setting the + timestamp to 1980-01-01. + Similar behavior occurs with files newer than 2107-12-31, + the timestamp is also set to the limit. .. note:: @@ -400,6 +405,9 @@ ZipFile Objects a closed ZipFile will raise a :exc:`ValueError`. Previously, a :exc:`RuntimeError` was raised. + .. versionadded:: 3.8 + The *strict_timestamps* keyword-only argument + .. method:: ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, \ compresslevel=None) @@ -540,7 +548,8 @@ information about a single member of the ZIP archive. There is one classmethod to make a :class:`ZipInfo` instance for a filesystem file: -.. classmethod:: ZipInfo.from_file(filename, arcname=None) +.. classmethod:: ZipInfo.from_file(filename, arcname=None, *, \ + strict_timestamps=True) Construct a :class:`ZipInfo` instance for a file on the filesystem, in preparation for adding it to a zip file. @@ -551,11 +560,20 @@ file: If *arcname* is not specified, the name will be the same as *filename*, but with any drive letter and leading path separators removed. + The *strict_timestamps* argument, when set to ``False``, allows to + zip files older than 1980-01-01 at the cost of setting the + timestamp to 1980-01-01. + Similar behavior occurs with files newer than 2107-12-31, + the timestamp is also set to the limit. + .. versionadded:: 3.6 .. versionchanged:: 3.6.2 The *filename* parameter accepts a :term:`path-like object`. + .. versionadded:: 3.8 + The *strict_timestamps* keyword-only argument + Instances have the following methods and attributes: |