]> granicus.if.org Git - python/commitdiff
Merged revisions 81094 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 11 May 2010 23:36:40 +0000 (23:36 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 11 May 2010 23:36:40 +0000 (23:36 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81094 | antoine.pitrou | 2010-05-12 01:32:31 +0200 (mer., 12 mai 2010) | 6 lines

  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).
........

Lib/test/test_zlib.py
Misc/NEWS

index 9b7c13597b9d1ffb755c005886c5cd3220844e10..8ff21835c68e34e33696371a4e54ef103d085fc9 100644 (file)
@@ -379,6 +379,19 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
         dco = zlib.decompressobj()
         self.assertEqual(dco.flush(), b"") # Returns nothing
 
+    def test_decompress_incomplete_stream(self):
+        # This is 'foo', deflated
+        x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
+        # For the record
+        self.assertEqual(zlib.decompress(x), b'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, b'foo')
+
     if hasattr(zlib.compressobj(), "copy"):
         def test_compresscopy(self):
             # Test copying a compression object
index cd1ed075372e0f1816ba7d604d97f6d1bd7db456..a351c80974ef1d170ad62a82c81c0915754bb1a8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1276,6 +1276,10 @@ Documentation
 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 #8533: regrtest uses backslashreplace error handler for stdout to avoid
   UnicodeEncodeError (write non-ASCII character to stdout using ASCII encoding)