New submission from Jason R. Coombs <[email protected]>:
While investigating #11638, I encountered another encoding issue related to
tarballs. Consider this command:
python -c "import gzip; gzip.GzipFile(u'\xe5rchive', 'w',
fileobj=open(u'\xe5rchive', 'wb'))"
When run, it triggers the following traceback:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\python\lib\gzip.py", line 127, in __init__
self._write_gzip_header()
File "c:\python\lib\gzip.py", line 172, in _write_gzip_header
self.fileobj.write(fname + '\000')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 0:
ordinal not in range(128)
Based on the resolution of #13639, I believe the recommended fix is to handle
unicode here much like Python 3 does--specifically, detect unicode, encode to
'latin-1' if possible or leave the filename blank if not.
----------
messages: 150265
nosy: jason.coombs
priority: low
severity: normal
status: open
title: UnicodeEncodeError in gzip when filename contains non-ascii
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13664>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com