Issue #4757: `zlib.compress` and other methods in the zlib module now
raise a TypeError when given an `str` object (rather than a `bytes`-like
object). Patch by Victor Stinner and Florent Xicluna.
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 08f9da5..f9a59d7 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -147,7 +147,7 @@
def _init_write(self, filename):
self.name = filename
- self.crc = zlib.crc32("") & 0xffffffff
+ self.crc = zlib.crc32(b"") & 0xffffffff
self.size = 0
self.writebuf = []
self.bufsize = 0
@@ -178,7 +178,7 @@
self.fileobj.write(fname + b'\000')
def _init_read(self):
- self.crc = zlib.crc32("") & 0xffffffff
+ self.crc = zlib.crc32(b"") & 0xffffffff
self.size = 0
def _read_gzip_header(self):