GZIPCompressedStream default read size to -1

To be compatible with the io.RawIOBase interface
the GZIPCompressedStream read method argument should be called
`size` and have a default value of -1 meaning until EOF.

See:
https://docs.python.org/3/library/io.html#io.RawIOBase

Change-Id: Ie8b4c77f6c730c91bb4d4997dcb7f9a9acde0f31
This commit is contained in:
Albin Vass 2020-11-27 17:58:59 +01:00
parent 3bbf04476c
commit 5b3a48e73b

View File

@ -125,6 +125,9 @@ ICON_IMAGES = {
# removed type annotations to support python2.
# removed use of *, somearg for positional anonymous args.
# Default compression level to 9.
#
# changed read method argument name from length to size and
# added read method default value size=-1 for parent class compatibility
class GZIPCompressedStream(io.RawIOBase):
def __init__(self, stream, compression_level=9):
@ -144,8 +147,8 @@ class GZIPCompressedStream(io.RawIOBase):
self._compressed_stream.seek(0)
self.count = 0
def read(self, length):
r = super().read(length)
def read(self, size=-1):
r = super().read(size)
self.count += len(r)
return r