Index: Lib/zipfile.py =================================================================== --- Lib/zipfile.py (version 67893) +++ Lib/zipfile.py (working copy) @@ -948,6 +948,11 @@ if targetpath[-1:] == "/": targetpath = targetpath[:-1] + isdir = False + + if member.filename[-1:] == "/": + isdir = True + # don't include leading "/" from file name if present if os.path.isabs(member.filename): targetpath = os.path.join(targetpath, member.filename[1:]) @@ -958,9 +963,13 @@ # Create all upper directories if necessary. upperdirs = os.path.dirname(targetpath) - if upperdirs and not os.path.exists(upperdirs): + if upperdirs and not os.path.isdir(upperdirs): os.makedirs(upperdirs) + if isdir: + os.mkdir(targetpath) + return targetpath + source = self.open(member, pwd=pwd) target = file(targetpath, "wb") shutil.copyfileobj(source, target)