From: Philipp Gesang Date: Mon, 27 Mar 2017 12:10:51 +0000 (+0200) Subject: unify zlib initialization X-Git-Tag: v2.2~7^2~208 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=57db1546a96784dd38eb92dc9e22c4160fa635d8;p=python-delta-tar unify zlib initialization --- diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index 9708f97..e4b6910 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -610,6 +610,22 @@ class _Stream: self.__write(self.name + NUL) + def _finalize_write_gz (self): + if self.cmp is not None: + chunk = self.buf + self.cmp.flush() + if chunk: + if self.comptype == "gz": + # The native zlib crc is an unsigned 32-bit integer, but + # the Python wrapper implicitly casts that to a signed C + # long. So, on a 32-bit box self.crc may "look negative", + # while the same crc on a 64-bit box may "look positive". + # To avoid irksome warnings from the `struct` module, force + # it to look positive on all boxes. + chunk += struct.pack("