Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c09c92f

Browse files
committed
Merged revisions 81094 via svnmerge from
svn+ssh://[email protected]/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). ........
1 parent 2d067c8 commit c09c92f

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lib/test/test_zlib.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,19 @@ def test_empty_flush(self):
379379
dco = zlib.decompressobj()
380380
self.assertEqual(dco.flush(), b"") # Returns nothing
381381

382+
def test_decompress_incomplete_stream(self):
383+
# This is 'foo', deflated
384+
x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
385+
# For the record
386+
self.assertEqual(zlib.decompress(x), b'foo')
387+
self.assertRaises(zlib.error, zlib.decompress, x[:-5])
388+
# Omitting the stream end works with decompressor objects
389+
# (see issue #8672).
390+
dco = zlib.decompressobj()
391+
y = dco.decompress(x[:-5])
392+
y += dco.flush()
393+
self.assertEqual(y, b'foo')
394+
382395
if hasattr(zlib.compressobj(), "copy"):
383396
def test_compresscopy(self):
384397
# Test copying a compression object

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,10 @@ Documentation
12761276
Tests
12771277
-----
12781278

1279+
- Issue #8672: Add a zlib test ensuring that an incomplete stream can be
1280+
handled by a decompressor object without errors (it returns incomplete
1281+
uncompressed data).
1282+
12791283
- Issue #8533: regrtest uses backslashreplace error handler for stdout to avoid
12801284
UnicodeEncodeError (write non-ASCII character to stdout using ASCII encoding)
12811285

0 commit comments

Comments
 (0)