This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients jaraco
Date 2011-12-20.01:23:21
SpamBayes Score 3.4915015e-11
Marked as misclassified No
Message-id <1324344204.12.0.0255632574169.issue13639@psf.upfronthosting.co.za>
In-reply-to
Content
python -c "import tarfile; tarfile.open(u'hello.tar.gz', 'w|gz')"

produces

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 1687, in open
    _Stream(name, filemode, comptype, fileobj, bufsize),
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 431, in __init__
    self._init_write_gz()
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 459, in _init_write_gz
    self.__write(self.name + NUL)
  File "C:\Users\jaraco\projects\public\cpython\Lib\tarfile.py", line 475, in __write
    self.buf += s
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)


Remove the compression ('|gz') or remove the unicode name or run under Python 3 and the command completes without error.

The error does not occur under Python 3 (even with non-ascii characters), so it should be possible to create a tarfile with a unicode filename on Python 2.7.

This failure is the underlying cause of #11638.
History
Date User Action Args
2011-12-20 01:23:24jaracosetrecipients: + jaraco
2011-12-20 01:23:24jaracosetmessageid: <1324344204.12.0.0255632574169.issue13639@psf.upfronthosting.co.za>
2011-12-20 01:23:23jaracolinkissue13639 messages
2011-12-20 01:23:21jaracocreate