diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-23 13:25:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-23 13:25:43 (GMT) |
commit | d4c2ac83944e48a02e5f11adba312d5b3b985150 (patch) | |
tree | 25dbafd2fa8763fa4388610ab9744c336433aac1 /Lib/gzip.py | |
parent | f6e31b79a873cce039070289bcf1d6fe434cb19e (diff) | |
download | cpython-d4c2ac83944e48a02e5f11adba312d5b3b985150.zip cpython-d4c2ac83944e48a02e5f11adba312d5b3b985150.tar.gz cpython-d4c2ac83944e48a02e5f11adba312d5b3b985150.tar.bz2 |
Issue #21560: An attempt to write a data of wrong type no longer cause
GzipFile corruption. Original patch by Wolfgang Maier.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index f934d4f..8b12225 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -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) |