diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-11-04 23:38:48 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-11-04 23:38:48 (GMT) |
commit | 519f43844babca8bb23cfc2cd0ba9f5ee0b26034 (patch) | |
tree | 0f59159b07393ff15c890bbfb1dd9f2a32e6fa6e /Lib | |
parent | ab60de478d70650a7a786d0d4a10ef6dcf1c2880 (diff) | |
parent | 39079946a257522ecb66cb068c872f5d1fe70ea3 (diff) | |
download | cpython-519f43844babca8bb23cfc2cd0ba9f5ee0b26034.zip cpython-519f43844babca8bb23cfc2cd0ba9f5ee0b26034.tar.gz cpython-519f43844babca8bb23cfc2cd0ba9f5ee0b26034.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')
-rw-r--r-- | Lib/test/test_zlib.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index d637c2d..b6a60f4 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -487,6 +487,20 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase): dco.flush() self.assertFalse(dco.eof) + 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.assertTrue(dco.eof) + 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 |