[issue9172] zipfile.extractall always raises an OSError after successfully unzipping all files

Teemu Rytkönen report at bugs.python.org
Sun Jul 25 20:34:14 CEST 2010

Teemu Rytkönen <teemu.rytkonen at gmail.com> added the comment:

I encountered the same problem and I debugged it a bit..
I think it not doing the entire unzipping again, but the problem is that the winzip packaged zip actually contains all file and directory entries and it fails trying to create already existing directory (because the dir has been created for the files that are in it).

I tried a quick and dirty fix for the zipfile _extract_member method, which basically should fix the problem! 

So here I create the directory only if it is not already existing, to get those empty directories created inside the zip.

959:        if member.filename[-1] == '/':
<add>           if not os.path.isdir(targetpath):
960:                os.mkdir(targetpath)

nosy: +terytkon
versions: +Python 2.6

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list