summaryrefslogtreecommitdiffstats
path: root/Doc/library/zipfile.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/zipfile.rst')
-rw-r--r--Doc/library/zipfile.rst42
1 files changed, 35 insertions, 7 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index d82ab06..75e8fd5 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -18,7 +18,7 @@ defined in `PKZIP Application Note
This module does not currently handle multi-disk ZIP files.
It can handle ZIP files that use the ZIP64 extensions
-(that is ZIP files that are more than 4 GByte in size). It supports
+(that is ZIP files that are more than 4 GiB in size). It supports
decryption of encrypted files in ZIP archives, but it currently cannot
create an encrypted file. Decryption is extremely slow as it is
implemented in native Python rather than C.
@@ -87,7 +87,30 @@ The module defines the following items:
.. data:: ZIP_DEFLATED
The numeric constant for the usual ZIP compression method. This requires the
- :mod:`zlib` module. No other compression methods are currently supported.
+ :mod:`zlib` module.
+
+
+.. data:: ZIP_BZIP2
+
+ The numeric constant for the BZIP2 compression method. This requires the
+ :mod:`bz2` module.
+
+ .. versionadded:: 3.3
+
+.. data:: ZIP_LZMA
+
+ The numeric constant for the LZMA compression method. This requires the
+ :mod:`lzma` module.
+
+ .. versionadded:: 3.3
+
+ .. note::
+
+ The ZIP file format specification has included support for bzip2 compression
+ since 2001, and for LZMA compression since 2006. However, some tools
+ (including older Python releases) do not support these compression
+ methods, and may either refuse to process the ZIP file altogether,
+ or fail to extract individual files.
.. seealso::
@@ -118,12 +141,14 @@ ZipFile Objects
adding a ZIP archive to another file (such as :file:`python.exe`). If
*mode* is ``a`` and the file does not exist at all, it is created.
*compression* is the ZIP compression method to use when writing the archive,
- and should be :const:`ZIP_STORED` or :const:`ZIP_DEFLATED`; unrecognized
- values will cause :exc:`RuntimeError` to be raised. If :const:`ZIP_DEFLATED`
- is specified but the :mod:`zlib` module is not available, :exc:`RuntimeError`
+ and should be :const:`ZIP_STORED`, :const:`ZIP_DEFLATED`,
+ :const:`ZIP_BZIP2` or :const:`ZIP_LZMA`; unrecognized
+ values will cause :exc:`RuntimeError` to be raised. If :const:`ZIP_DEFLATED`,
+ :const:`ZIP_BZIP2` or :const:`ZIP_LZMA` is specified but the corresponded module
+ (:mod:`zlib`, :mod:`bz2` or :mod:`lzma`) is not available, :exc:`RuntimeError`
is also raised. The default is :const:`ZIP_STORED`. If *allowZip64* is
``True`` zipfile will create ZIP files that use the ZIP64 extensions when
- the zipfile is larger than 2 GB. If it is false (the default) :mod:`zipfile`
+ the zipfile is larger than 2 GiB. If it is false (the default) :mod:`zipfile`
will raise an exception when the ZIP file would require ZIP64 extensions.
ZIP64 extensions are disabled by default because the default :program:`zip`
and :program:`unzip` commands on Unix (the InfoZIP utilities) don't support
@@ -143,6 +168,9 @@ ZipFile Objects
.. versionadded:: 3.2
Added the ability to use :class:`ZipFile` as a context manager.
+ .. versionchanged:: 3.3
+ Added support for :mod:`bzip2 <bz2>` and :mod:`lzma` compression.
+
.. method:: ZipFile.close()
@@ -239,7 +267,7 @@ ZipFile Objects
that have absolute filenames starting with ``"/"`` or filenames with two
dots ``".."``.
- .. versionchanged:: 3.2.4
+ .. versionchanged:: 3.3.1
The zipfile module attempts to prevent that. See :meth:`extract` note.