File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ def read(self, size=-1):
268268 if tail :
269269 # move the window, make it as large as size demands. For code-clarity,
270270 # we just take the chunk from our map again instead of reusing the unconsumed
271- # tail. The latter one would safe some memory copying, but we could end up
271+ # tail. The latter one would save some memory copying, but we could end up
272272 # with not getting enough data uncompressed, so we had to sort that out as well.
273273 # Now we just assume the worst case, hence the data is uncompressed and the window
274274 # needs to be as large as the uncompressed bytes we want to read.
@@ -313,7 +313,10 @@ def read(self, size=-1):
313313 consumed = len (indata ) - unused_datalen
314314 self ._cbr += consumed
315315 self ._br += len (chunk )
316- dcompdat += chunk
316+ if chunk :
317+ if not isinstance (dcompdat , bytearray ):
318+ dcompdat = bytearray (dcompdat )
319+ dcompdat .extend (chunk )
317320
318321 # Stop when we have enough or there is no path to more output.
319322 # `chunk` may legitimately be empty mid-stream when zlib is
Original file line number Diff line number Diff line change @@ -179,7 +179,8 @@ def test_decompress_reader_chunked_read_does_not_terminate_early(self):
179179 data = b"hello world! " * 1000
180180 zdata = zlib .compress (data )
181181
182- # Loop with a small chunk size to force many sub-_s recursions.
182+ # Loop with a small chunk size to force many internal read/decompression
183+ # iterations before EOF.
183184 for chunk_size in (1 , 4 , 16 , 64 ):
184185 reader = DecompressMemMapReader (
185186 zdata , close_on_deletion = False , size = len (data )
You can’t perform that action at this time.
0 commit comments