Message186264
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 |
|
Date |
User |
Action |
Args |
2013-04-08 03:20:59 | Vhati | set | recipients:
+ Vhati, ezio.melotti |
2013-04-08 03:20:59 | Vhati | set | messageid: <1365391259.55.0.44522935247.issue17656@psf.upfronthosting.co.za> |
2013-04-08 03:20:59 | Vhati | link | issue17656 messages |
2013-04-08 03:20:58 | Vhati | create | |
|