[New-bugs-announce] [issue15602] zipfile: wrong encoding charset of member filename
report at bugs.python.org
Thu Aug 9 08:20:46 CEST 2012
New submission from monson:
In /cpython/Lib/zipfile.py, there are some codes like
if flags & 0x800:
# UTF-8 file names extension
filename = filename.decode('utf-8')
# Historical ZIP filename encoding
filename = filename.decode('cp437')
But actually there is no "Historical ZIP filename encoding", because zip files contain no charset info.
In English countries, it's usually not a big deal. But if the files zip on a non-cp437-based system (especially like China or Japan), filename is encoded from charsets like gb18030, but ZipFile decodes the byte stream to cp437, then everything goes wrong and people are hard to find the reason.
It's a problem new in py3k, and I found it on python3.2 and python3.4.
I suggest the filename returned in Bytes objects, or add decoding parameter when opening zipfile.
components: Library (Lib)
title: zipfile: wrong encoding charset of member filename
versions: Python 3.2
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce