[issue4621] zipfile returns string but expects binary

Eddie report at bugs.python.org
Thu Dec 18 15:17:54 CET 2008


Eddie <skreft at gmail.com> added the comment:

Sorry, my bad.
I did tried it but with the wrong version (2.5). And it worked perfectly.

So sorry again for my mistake.

Anyways, I've found the error.

The problem is caused by different encodings used when zipping.

In open, the method is comparing b't\x82st.xml' against
b't\xc3\xa9st.xml', and of course they are different.
But they are no so different, because b't\x82st.xml' is
'tést'.encode('cp437') and b't\xc3\xa9st.xml' is 'tést'.encode(utf-8).

The problem arises because the open method supposes the filename is in
utf-8 encoding, but in __init__ it realizes that the encoding depends on
the flags. 
if flags & 0x800:
    filename = filename.decode.('utf-8')
else:
    filename = filename.decode.('cp437')

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


More information about the Python-bugs-list mailing list