[Python-checkins] cpython: Issue #26039: Document ZipInfo.is_dir() and make force_zip64 keyword-only.

serhiy.storchaka python-checkins at python.org
Sun May 15 05:27:45 EDT 2016


https://hg.python.org/cpython/rev/29b470b8ab77
changeset:   101344:29b470b8ab77
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun May 15 12:27:16 2016 +0300
summary:
  Issue #26039: Document ZipInfo.is_dir() and make force_zip64 keyword-only.
Patch by Thomas Kluyver.

files:
  Doc/library/zipfile.rst |  12 ++++++++++--
  Lib/zipfile.py          |   3 ++-
  2 files changed, 12 insertions(+), 3 deletions(-)


diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -207,7 +207,7 @@
 .. index::
    single: universal newlines; zipfile.ZipFile.open method
 
-.. method:: ZipFile.open(name, mode='r', pwd=None, force_zip64=False)
+.. method:: ZipFile.open(name, mode='r', pwd=None, *, force_zip64=False)
 
    Access a member of the archive as a file-like object.  *name*
    is the name of the file in the archive, or a :class:`ZipInfo` object.  The
@@ -490,7 +490,15 @@
 
    .. versionadded:: 3.6
 
-Instances have the following attributes:
+Instances have the following methods and attributes:
+
+.. method:: ZipInfo.is_dir()
+
+   Return True if this archive member is a directory.
+
+   This uses the entry's name: directories should always end with ``/``.
+
+   .. versionadded:: 3.6
 
 
 .. attribute:: ZipInfo.filename
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -502,6 +502,7 @@
         return zinfo
 
     def is_dir(self):
+        """Return True if this archive member is a directory."""
         return self.filename[-1] == '/'
 
 
@@ -1343,7 +1344,7 @@
         with self.open(name, "r", pwd) as fp:
             return fp.read()
 
-    def open(self, name, mode="r", pwd=None, force_zip64=False):
+    def open(self, name, mode="r", pwd=None, *, force_zip64=False):
         """Return file-like object for 'name'.
 
         name is a string for the file name within the ZIP file, or a ZipInfo

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list