]> granicus.if.org Git - python/commitdiff
Bug #1704156: Support for unicode strings as input filenames is
authorLars Gustäbel <lars@gustaebel.de>
Sat, 21 Apr 2007 12:20:09 +0000 (12:20 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Sat, 21 Apr 2007 12:20:09 +0000 (12:20 +0000)
neither documented nor intended but works in Python 2.4 under certain
conditions. This stopped working in 2.5 because struct.pack is used.
This small patch restores the old behaviour. A more solid solution is
planned for 2.6.

Lib/tarfile.py

index 474e306e4c070bd3c6bc836d78e6cb7a51d65f40..8afea475d8be5d858045da19ae5e5eb17ebc85ed 100644 (file)
@@ -963,7 +963,7 @@ class TarInfo(object):
             stn(prefix, 155)
         ]
 
-        buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts))
+        buf += "".join(parts).ljust(BLOCKSIZE, NUL)
         chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
         buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
         self.buf = buf