diff options
| -rw-r--r-- | Lib/tarfile.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 47bc871..c185fbd 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -417,7 +417,13 @@ class _Stream: self.fileobj.write(self.buf) self.buf = "" if self.comptype == "gz": - self.fileobj.write(struct.pack("<l", self.crc)) + # 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. + self.fileobj.write(struct.pack("<L", self.crc & 0xffffffffL)) self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFFL)) if not self._extfileobj: |
