[issue4621] zipfile returns string but expects binary

Francesco Ricciardi report at bugs.python.org
Thu Dec 18 08:33:04 CET 2008


Francesco Ricciardi <francesco.ricciardi at hp.com> added the comment:

If that is what is requested, then the manual entry for ZipFile.read
must be corrected, because it states:

"ZipFile.read(name[, pwd]) .... name is the name of the file in the
archive, or a ZipInfo object."


However, Eddie, you haven't tried what you suggested, because this is
what you would get:

>>> import zipfile
>>> testzip = zipfile.ZipFile('test.zip')
>>> t1 = testzip.infolist()[0]
>>> t1.filename
'tést.xml'
>>> data = testzip.read(t1.filename)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python30\lib\zipfile.py", line 843, in read
    return self.open(name, "r", pwd).read()
  File "C:\Python30\lib\zipfile.py", line 883, in open
    % (zinfo.orig_filename, fname))
zipfile.BadZipfile: File name in directory 'tést.xml' and header
b't\x82st.xml' differ.

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


More information about the Python-bugs-list mailing list