Nikolaus Rath added the comment: Is there any reason why unconsumed_tail needs to be exposted?
I would suggest to instead introduce a boolean attribute data_ready than indicates that more decompressed data can be provided without additional compressed input. Example: # decomp = decompressor object # infh = compressed input stream # outfh = decompressed output stream while not decomp.eof: if decomp.data_ready: buf = decomp.decompress(max_size=BUFSIZE) # or maybe: #buf = decomp.decompress(b'', max_size=BUFSIZE) else: buf = infh.read(BUFSIZE) if not buf: raise RuntimeError('Unexpected end of compressed stream') buf = decomp.decompress(buf, max_size=BUFSIZE) assert len(buf) > 0 outfh.write(buf) This is short, easily readable (in my opinion) and also avoids the problem where the decompressor blocks because it needs more data even though there still is an unconsumed tail. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15955> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com