changeset: 92130:ffa5bfe75c3a branch: 2.7 user: Serhiy Storchaka date: Sun Aug 17 15:11:06 2014 +0300 files: Lib/zipfile.py Misc/NEWS description: Issue #22201: Command-line interface of the zipfile module now correctly extracts ZIP files with directory entries. Patch by Ryan Wilson. diff -r 2e417d9a2b1c -r ffa5bfe75c3a Lib/zipfile.py --- a/Lib/zipfile.py Sun Aug 17 13:29:13 2014 +0300 +++ b/Lib/zipfile.py Sun Aug 17 15:11:06 2014 +0300 @@ -1492,18 +1492,7 @@ 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 -r 2e417d9a2b1c -r ffa5bfe75c3a Misc/NEWS --- a/Misc/NEWS Sun Aug 17 13:29:13 2014 +0300 +++ b/Misc/NEWS Sun Aug 17 15:11:06 2014 +0300 @@ -84,6 +84,12 @@ 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 -----