mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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.
This commit is contained in:
parent
338eae3460
commit
77b338be20
5 changed files with 52 additions and 31 deletions
|
@ -147,7 +147,7 @@ class GzipFile:
|
|||
|
||||
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 @@ class GzipFile:
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue