Title: does fails with UnicodeDecodeError if parent dir is unicode
Type: Stage:
Components: Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: parthm, vstinner
Priority: normal Keywords:

Created on 2010-04-14 09:50 by parthm, last changed 2010-04-14 10:00 by vstinner. This issue is now closed.

File name Uploaded Description Edit parthm, 2010-04-14 09:50
Messages (3)
msg103117 - (view) Author: Parth Malwankar (parthm) Date: 2010-04-14 09:50
If any directory higher up in the hierarchy contains unicode chars, fails with UnicodeDecodeError. Attached script reproduces this error.

[tmp]% python 
Traceback (most recent call last):
  File "", line 9, in <module>, 'w')
  File "/usr/lib/python2.6/", line 1682, in open
    return cls.taropen(name, mode, fileobj, **kwargs)
  File "/usr/lib/python2.6/", line 1692, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/usr/lib/python2.6/", line 1527, in __init__ = os.path.abspath(name) if name else None
  File "/usr/lib/python2.6/", line 338, in abspath
    path = join(os.getcwd(), path)
  File "/usr/lib/python2.6/", line 70, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 17: ordinal not in range(128)
msg103118 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-14 09:54
It looks like tarfile doesn't support unicode filenames. You should try to encode your input filename to the file system default encoding (sys.getfilesystemencoding()), or avoid using unicode for tar filenames.
msg103119 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-14 10:00
I proposed a workaround, the real bug is that os.path.abspath() doesn't support unicode... And this bug was already fixed 7 weeks ago by r78247 (issue #3426).

Python 2.6.5 and 2.7b1 are fixed. So please upgrade :-)
Date User Action Args
2010-04-14 10:00:16vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg103119
2010-04-14 09:54:30vstinnersetnosy: + vstinner
messages: + msg103118
2010-04-14 09:50:02parthmcreate