diff -r 3d45155b7b9b Lib/zipfile.py --- a/Lib/zipfile.py Sat Aug 16 22:54:24 2014 +0530 +++ b/Lib/zipfile.py Sat Aug 16 12:22:05 2014 -0700 @@ -1764,18 +1764,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: @@ -1786,6 +1775,8 @@ if os.path.isfile(path): zf.write(path, zippath, ZIP_DEFLATED) elif os.path.isdir(path): + if not os.listdir(path): + zf.write(path, zippath, ZIP_DEFLATED) for nm in os.listdir(path): addToZip(zf, os.path.join(path, nm), os.path.join(zippath, nm))