Issue #13639: Accept unicode filenames in tarfile.open(mode="w|gz").

Passing a unicode filename to tarfile.open() along with mode "w|gz" failed
with a UnicodeError because the filename was not encoded properly before being
written to the gzipped stream in the FNAME extra field.
This commit is contained in:
Lars Gustäbel 2011-12-21 19:27:50 +01:00
parent 5b95eb90a7
commit 7d4d074c99
3 changed files with 11 additions and 0 deletions

View file

@ -994,6 +994,13 @@ class StreamWriteTest(WriteTestBase):
finally:
os.umask(original_umask)
def test_issue13639(self):
try:
with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode):
pass
except UnicodeDecodeError:
self.fail("_Stream failed to write unicode filename")
class GNUWriteTest(unittest.TestCase):
# This testcase checks for correct creation of GNU Longname