summaryrefslogtreecommitdiff
path: root/Doc/library/zipfile.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-08 14:37:51 +0200
committerGitHub <noreply@github.com>2017-03-08 14:37:51 +0200
commit8606e9524a7a4065042f7f228dc57eb74f88e4d3 (patch)
tree84f0e487deb92a304f8a584e59217d3b25351f98 /Doc/library/zipfile.rst
parentc351ce6a2c923c5016e48ecbf7b1e4833031d154 (diff)
downloadcpython-git-8606e9524a7a4065042f7f228dc57eb74f88e4d3.tar.gz
bpo-28231: The zipfile module now accepts path-like objects for external paths. (#511)
Diffstat (limited to 'Doc/library/zipfile.rst')
-rw-r--r--Doc/library/zipfile.rst24
1 files changed, 22 insertions, 2 deletions
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index a0de10cae3..4cde1dd76a 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -132,8 +132,9 @@ ZipFile Objects
.. class:: ZipFile(file, mode='r', compression=ZIP_STORED, allowZip64=True)
- Open a ZIP file, where *file* can be either a path to a file (a string) or a
- file-like object. The *mode* parameter should be ``'r'`` to read an existing
+ Open a ZIP file, where *file* can be a path to a file (a string), a
+ file-like object or a :term:`path-like object`.
+ The *mode* parameter should be ``'r'`` to read an existing
file, ``'w'`` to truncate and write a new file, ``'a'`` to append to an
existing file, or ``'x'`` to exclusively create and write a new file.
If *mode* is ``'x'`` and *file* refers to an existing file,
@@ -183,6 +184,9 @@ ZipFile Objects
Previously, a plain :exc:`RuntimeError` was raised for unrecognized
compression values.
+ .. versionchanged:: 3.6.2
+ The *file* parameter accepts a :term:`path-like object`.
+
.. method:: ZipFile.close()
@@ -284,6 +288,9 @@ ZipFile Objects
Calling :meth:`extract` on a closed ZipFile will raise a
:exc:`ValueError`. Previously, a :exc:`RuntimeError` was raised.
+ .. versionchanged:: 3.6.2
+ The *path* parameter accepts a :term:`path-like object`.
+
.. method:: ZipFile.extractall(path=None, members=None, pwd=None)
@@ -304,6 +311,9 @@ ZipFile Objects
Calling :meth:`extractall` on a closed ZipFile will raise a
:exc:`ValueError`. Previously, a :exc:`RuntimeError` was raised.
+ .. versionchanged:: 3.6.2
+ The *path* parameter accepts a :term:`path-like object`.
+
.. method:: ZipFile.printdir()
@@ -403,6 +413,9 @@ ZipFile Objects
The following data attributes are also available:
+.. attribute:: ZipFile.filename
+
+ Name of the ZIP file.
.. attribute:: ZipFile.debug
@@ -488,6 +501,9 @@ The :class:`PyZipFile` constructor takes the same parameters as the
.. versionadded:: 3.4
The *filterfunc* parameter.
+ .. versionchanged:: 3.6.2
+ The *pathname* parameter accepts a :term:`path-like object`.
+
.. _zipinfo-objects:
@@ -514,6 +530,10 @@ file:
.. versionadded:: 3.6
+ .. versionchanged:: 3.6.2
+ The *filename* parameter accepts a :term:`path-like object`.
+
+
Instances have the following methods and attributes:
.. method:: ZipInfo.is_dir()