summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-11-04 23:37:42 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-11-04 23:37:42 (GMT)
commit39079946a257522ecb66cb068c872f5d1fe70ea3 (patch)
tree4c5fe8fa06bde62f9d7cfff518d8c8b23040ac38 /Lib/test/test_zlib.py
parent6c5f5210be9f68252b72d7b5e8dc2bde20d90c9d (diff)
downloadcpython-39079946a257522ecb66cb068c872f5d1fe70ea3.zip
cpython-39079946a257522ecb66cb068c872f5d1fe70ea3.tar.gz
cpython-39079946a257522ecb66cb068c872f5d1fe70ea3.tar.bz2
Issue #16350: Fix zlib decompressor handling of unused_data with multiple calls to decompress() after EOF.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 60081e2..c17b4d0 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -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