Issue 8396: tarfile.open does fails with UnicodeDecodeError if parent dir is unicode (original) (raw)

If any directory higher up in the hierarchy contains unicode chars, tarfile.open fails with UnicodeDecodeError. Attached script reproduces this error.

[tmp]% python tarfilefail.py Traceback (most recent call last): File "tarfilefail.py", line 9, in tarfile.open(file_name, 'w') File "/usr/lib/python2.6/tarfile.py", line 1682, in open return cls.taropen(name, mode, fileobj, **kwargs) File "/usr/lib/python2.6/tarfile.py", line 1692, in taropen return cls(name, mode, fileobj, **kwargs) File "/usr/lib/python2.6/tarfile.py", line 1527, in init self.name = os.path.abspath(name) if name else None File "/usr/lib/python2.6/posixpath.py", line 338, in abspath path = join(os.getcwd(), path) File "/usr/lib/python2.6/posixpath.py", line 70, in join path += '/' + b UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 17: ordinal not in range(128) [tmp]%