mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Issue #16350: Fix zlib decompressor handling of unused_data with multiple calls to decompress() after EOF.
Patch by Serhiy Storchaka.
This commit is contained in:
parent
6c5f5210be
commit
39079946a2
3 changed files with 40 additions and 6 deletions
|
|
@ -434,6 +434,19 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
|
|||
y += dco.flush()
|
||||
self.assertEqual(y, b'foo')
|
||||
|
||||
def test_decompress_unused_data(self):
|
||||
# Repeated calls to decompress() after EOF should accumulate data in
|
||||
# dco.unused_data, instead of just storing the arg to the last call.
|
||||
x = zlib.compress(HAMLET_SCENE) + HAMLET_SCENE
|
||||
for step in 1, 2, 100:
|
||||
dco = zlib.decompressobj()
|
||||
data = b''.join(dco.decompress(x[i : i + step])
|
||||
for i in range(0, len(x), step))
|
||||
data += dco.flush()
|
||||
|
||||
self.assertEqual(data, HAMLET_SCENE)
|
||||
self.assertEqual(dco.unused_data, HAMLET_SCENE)
|
||||
|
||||
if hasattr(zlib.compressobj(), "copy"):
|
||||
def test_compresscopy(self):
|
||||
# Test copying a compression object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue