Issue #21560: An attempt to write a data of wrong type no longer cause

GzipFile corruption.  Original patch by Wolfgang Maier.
This commit is contained in:
Serhiy Storchaka 2015-03-23 15:25:43 +02:00
parent f6e31b79a8
commit d4c2ac8394
3 changed files with 38 additions and 2 deletions

View file

@ -339,9 +339,9 @@ class GzipFile(io.BufferedIOBase):
data = data.tobytes()
if len(data) > 0:
self.size = self.size + len(data)
self.fileobj.write(self.compress.compress(data))
self.size += len(data)
self.crc = zlib.crc32(data, self.crc) & 0xffffffff
self.fileobj.write( self.compress.compress(data) )
self.offset += len(data)
return len(data)