Index: Lib/tarfile.py =================================================================== --- Lib/tarfile.py (revision 51424) +++ Lib/tarfile.py (working copy) @@ -411,9 +411,6 @@ self.buf += self.cmp.flush() if self.mode == "w" and self.buf: - blocks, remainder = divmod(len(self.buf), self.bufsize) - if remainder > 0: - self.buf += NUL * (self.bufsize - remainder) self.fileobj.write(self.buf) self.buf = "" if self.comptype == "gz": Index: Lib/test/test_tarfile.py =================================================================== --- Lib/test/test_tarfile.py (revision 51424) +++ Lib/test/test_tarfile.py (working copy) @@ -324,6 +324,31 @@ class WriteStreamTest(WriteTest): sep = '|' + def test_padding(self): + self.dst.close() + + if self.comp == "gz": + f = gzip.GzipFile(self.dstname) + s = f.read() + f.close() + + elif self.comp == "bz2": + f = bz2.BZ2Decompressor() + s = file(self.dstname).read() + s = f.decompress(s) + + self.assertEqual(len(f.unused_data), 0, + "trailing data") + + else: + f = file(self.dstname) + s = f.read() + f.close() + + self.assertEqual(s.count("\0"), tarfile.RECORDSIZE, + "incorrect zero padding") + + class WriteGNULongTest(unittest.TestCase): """This testcase checks for correct creation of GNU Longname and Longlink extensions.