[issue6839] zipfile can't extract file

Adam Polkosnik report at bugs.python.org
Fri May 2 21:30:24 CEST 2014


Adam Polkosnik added the comment:

Ethan,
I'd refer you to msg92309...

And
When testing with WinZip it looks like this: 
No errors detected in compressed data of C:\Downloads\test.zip.
Testing ...
Testing test\                    OK
Testing test\test2.txt           OK
Testing test1.txt                OK

Then in python:
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipfile
>>> zf =  zipfile.ZipFile('test.zip')
>>> namelist = zf.namelist()
>>> namelist
['test/', 'test/test2.txt', 'test1.txt']
>>> for af in namelist:
...     zf.read(af)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "c:\Python34\lib\zipfile.py", line 1117, in read
    with self.open(name, "r", pwd) as fp:
  File "c:\Python34\lib\zipfile.py", line 1180, in open
    % (zinfo.orig_filename, fname))
zipfile.BadZipFile: File name in directory 'test\\' and header b'test/' differ.

So, based on that everything is already converted to forward slashes for the extraction.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6839>
_______________________________________


More information about the Python-bugs-list mailing list