]> granicus.if.org Git - python/commitdiff
Issue #22201: Command-line interface of the zipfile module now correctly
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 Aug 2014 12:11:06 +0000 (15:11 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 Aug 2014 12:11:06 +0000 (15:11 +0300)
extracts ZIP files with directory entries.  Patch by Ryan Wilson.

Lib/zipfile.py
Misc/NEWS

index a0beae2a60562907669e6ffc710ba88423e03e0e..fe71765af02a48a3b6ed06c952e4271862e3cd7b 100644 (file)
@@ -1492,18 +1492,7 @@ def main(args = None):
             sys.exit(1)
 
         with ZipFile(args[1], 'r') as zf:
-            out = args[2]
-            for path in zf.namelist():
-                if path.startswith('./'):
-                    tgt = os.path.join(out, path[2:])
-                else:
-                    tgt = os.path.join(out, path)
-
-                tgtdir = os.path.dirname(tgt)
-                if not os.path.exists(tgtdir):
-                    os.makedirs(tgtdir)
-                with open(tgt, 'wb') as fp:
-                    fp.write(zf.read(path))
+            zf.extractall(args[2])
 
     elif args[0] == '-c':
         if len(args) < 3:
index 86deb58cdebef4ab57384092c40877dc27de4aab..5f731bf7ecbd65179bb679357d7aaa5a6c7ab133 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -84,6 +84,12 @@ Extension Modules
   adds support for the Linux AArch64 and POWERPC ELF ABIv2 little endian
   architectures.
 
+Tools/Demos
+-----------
+
+- Issue #22201: Command-line interface of the zipfile module now correctly
+  extracts ZIP files with directory entries.  Patch by Ryan Wilson.
+
 Tests
 -----