| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 81cf3e5 commit ed41d2c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,7 +268,7 @@ def read(self, size=-1): | |||
| 268 | 268 | if tail: | |
| 269 | 269 | # move the window, make it as large as size demands. For code-clarity, | |
| 270 | 270 | # 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 | ||
| 272 | 272 | # with not getting enough data uncompressed, so we had to sort that out as well. | |
| 273 | 273 | # Now we just assume the worst case, hence the data is uncompressed and the window | |
| 274 | 274 | # needs to be as large as the uncompressed bytes we want to read. | |
@@ -313,7 +313,10 @@ def read(self, size=-1): | |||
| 313 | 313 | consumed = len(indata) - unused_datalen | |
| 314 | 314 | self._cbr += consumed | |
| 315 | 315 | self._br += len(chunk) | |
| 316 | - dcompdat += chunk | ||
| 316 | + if chunk: | ||
| 317 | + if not isinstance(dcompdat, bytearray): | ||
| 318 | + dcompdat = bytearray(dcompdat) | ||
| 319 | + dcompdat.extend(chunk) | ||
| 317 | 320 | ||
| 318 | 321 | # Stop when we have enough or there is no path to more output. | |
| 319 | 322 | # `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): | |||
| 179 | 179 | data = b"hello world! " * 1000 | |
| 180 | 180 | zdata = zlib.compress(data) | |
| 181 | 181 | ||
| 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. | ||
| 183 | 184 | for chunk_size in (1, 4, 16, 64): | |
| 184 | 185 | reader = DecompressMemMapReader( | |
| 185 | 186 | zdata, close_on_deletion=False, size=len(data) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments