]> granicus.if.org Git - python/commitdiff
Issue #8672: Add a zlib test ensuring that an incomplete stream can be
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 11 May 2010 23:32:31 +0000 (23:32 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 11 May 2010 23:32:31 +0000 (23:32 +0000)
handled by a decompressor object without errors (it returns incomplete
uncompressed data).

Lib/test/test_zlib.py
Misc/NEWS

index cd021750d7e7f795c2e4952977fe39d6ce512b87..2fc43139a2f6d0ee6f4f184ce9a207e5598b8e5c 100644 (file)
@@ -361,6 +361,19 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
         dco = zlib.decompressobj()
         self.assertEqual(dco.flush(), "") # Returns nothing
 
+    def test_decompress_incomplete_stream(self):
+        # This is 'foo', deflated
+        x = 'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
+        # For the record
+        self.assertEqual(zlib.decompress(x), 'foo')
+        self.assertRaises(zlib.error, zlib.decompress, x[:-5])
+        # Omitting the stream end works with decompressor objects
+        # (see issue #8672).
+        dco = zlib.decompressobj()
+        y = dco.decompress(x[:-5])
+        y += dco.flush()
+        self.assertEqual(y, 'foo')
+
     if hasattr(zlib.compressobj(), "copy"):
         def test_compresscopy(self):
             # Test copying a compression object
index a09d53587c0dacd03eabe1cdd6ff9dab7596d5b8..e46162d01699866d3133f022fd28ea2f9a71dc3a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -216,6 +216,10 @@ Extension Modules
 Tests
 -----
 
+- Issue #8672: Add a zlib test ensuring that an incomplete stream can be
+  handled by a decompressor object without errors (it returns incomplete
+  uncompressed data).
+
 - Issue #8490: asyncore now has a more solid test suite which actually tests 
   its API.