Skip to content

Commit e3bf6ea

Browse files
committed
Use eof instance variable to determine whether compression has ended.
The unconsumed tail has a possibility to be empty, even if the end of compression is not reached
1 parent 1b328ea commit e3bf6ea

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/test/test_zlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def test_decompimax(self, source=None, cx=256, dcx=64):
358358
dco = zlib.decompressobj()
359359
bufs = []
360360
cb = combuf
361-
while cb:
361+
while not dco.eof:
362362
#max_length = 1 + len(cb)//10
363363
chunk = dco.decompress(cb, dcx)
364364
self.assertFalse(len(chunk) > dcx,
@@ -383,7 +383,7 @@ def test_decompressmaxlen(self, flush=False):
383383
dco = zlib.decompressobj()
384384
bufs = []
385385
cb = combuf
386-
while cb:
386+
while not dco.eof:
387387
max_length = 1 + len(cb)//10
388388
chunk = dco.decompress(cb, max_length)
389389
self.assertFalse(len(chunk) > max_length,
@@ -393,7 +393,7 @@ def test_decompressmaxlen(self, flush=False):
393393
if flush:
394394
bufs.append(dco.flush())
395395
else:
396-
while chunk:
396+
while not dco.eof:
397397
chunk = dco.decompress(b'', max_length)
398398
self.assertFalse(len(chunk) > max_length,
399399
'chunk too big (%d>%d)' % (len(chunk),max_length))

0 commit comments

Comments
 (0)