New submission from Vhati: Python 2.7.4 fails while extracting zip files when 'member' is a unicode path.
--- Traceback (most recent call last): ... my_zip.extract(item, tmp_folder_path) File "D:\Apps\Python274\lib\zipfile.py", line 1024, in extract return self._extract_member(member, path, pwd) File "D:\Apps\Python274\lib\zipfile.py", line 1057, in _extract_member arcname = arcname.translate(table) TypeError: character mapping must return integer, None or unicode --- 2.7.3 had no problems because the call to translate() is new. The following, copied from ZipFile.py, will recreate the error. -- import string illegal = ':<>|"?*' table = string.maketrans(illegal, '_' * len(illegal)) arcname = "hi" arcname = arcname.translate(table) # ascii strings are fine arcname = u"hi" arcname = arcname.translate(table) # unicode fails # Traceback (most recent call last): # File "<stdin>", line 1, in <module> # TypeError: character mapping must return integer, None or unicode --- I tried using unicode literals for the illegal string and maketrans underscore arg, but that didn't work. Suggestions? Here's a link to the doc for translate(). http://docs.python.org/2/library/stdtypes.html#str.translate ---------- components: Unicode messages: 186264 nosy: Vhati, ezio.melotti priority: normal severity: normal status: open title: Python 2.7.4 Breaks ZipFile Extraction type: crash versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17656> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com