diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-04-21 08:46:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 08:46:39 (GMT) |
commit | 51ef89cd9acbfbfa7fd8d82f0c6baa388bb650c9 (patch) | |
tree | eb6f52baa37360fb86c7401d12c47f51ad3795af /Doc/library/zipfile.rst | |
parent | ccda73828473576c57d1bb31774f56542d6e8964 (diff) | |
download | cpython-51ef89cd9acbfbfa7fd8d82f0c6baa388bb650c9.zip cpython-51ef89cd9acbfbfa7fd8d82f0c6baa388bb650c9.tar.gz cpython-51ef89cd9acbfbfa7fd8d82f0c6baa388bb650c9.tar.bz2 |
gh-115961: Add name and mode attributes for compressed file-like objects (GH-116036)
* Add name and mode attributes for compressed and archived file-like objects
in modules bz2, lzma, tarfile and zipfile.
* Change the value of the mode attribute of GzipFile from integer (1 or 2)
to string ('rb' or 'wb').
* Change the value of the mode attribute of ZipExtFile from 'r' to 'rb'.
Diffstat (limited to 'Doc/library/zipfile.rst')
-rw-r--r-- | Doc/library/zipfile.rst | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index ee53f16..6192689 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -301,6 +301,10 @@ ZipFile Objects attempting to read or write other files in the ZIP file will raise a :exc:`ValueError`. + In both cases the file-like object has also attributes :attr:`!name`, + which is equivalent to the name of a file within the archive, and + :attr:`!mode`, which is ``'rb'`` or ``'wb'`` depending on the input mode. + When writing a file, if the file size is not known in advance but may exceed 2 GiB, pass ``force_zip64=True`` to ensure that the header format is capable of supporting large files. If the file size is known in advance, @@ -325,6 +329,12 @@ ZipFile Objects Calling :meth:`.open` on a closed ZipFile will raise a :exc:`ValueError`. Previously, a :exc:`RuntimeError` was raised. + .. versionchanged:: 3.13 + Added attributes :attr:`!name` and :attr:`!mode` for the writeable + file-like object. + The value of the :attr:`!mode` attribute for the readable file-like + object was changed from ``'r'`` to ``'rb'``. + .. method:: ZipFile.extract(member, path=None, pwd=None) |