From: Serhiy Storchaka Date: Sun, 17 Aug 2014 12:14:48 +0000 (+0300) Subject: Issue #22201: Command-line interface of the zipfile module now correctly X-Git-Tag: v3.4.2rc1~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97f17ff8405e1b6741ff1b1412befd0190896ae7;p=python Issue #22201: Command-line interface of the zipfile module now correctly extracts ZIP files with directory entries. Patch by Ryan Wilson. --- diff --git a/Lib/zipfile.py b/Lib/zipfile.py index ee228b1475..c57765753f 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1764,18 +1764,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: diff --git a/Misc/NEWS b/Misc/NEWS index 71304b3fcc..15f2b82597 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -329,6 +329,9 @@ Windows Tools/Demos ----------- +- Issue #22201: Command-line interface of the zipfile module now correctly + extracts ZIP files with directory entries. Patch by Ryan Wilson. + - Issue #21906: Make Tools/scripts/md5sum.py work in Python 3. Patch by Zachary Ware.