Nadeem Vawda added the comment: The cause of this problem is that BZ2File.read1() sometimes returns b"", even though the file is not at EOF. This happens when the underlying BZ2Decompressor cannot produce any decompressed data from just the block passed to it in _fill_buffer(); in this case, it needs to read more of the compressed stream to make progress.
It would seem that BZ2File cannot satisfy the contract of the read1() method - we can't guarantee that a single call to the read() method of the underlying file will allow us to return a non-empty result, whereas returning b"" is reserved for the case where we have reached EOF. Simply removing the read1() method would simply trade this problem for a bigger one (resurrecting issue 10791), so I propose amending BZ2File.read1() to make as many reads from the underlying file as necessary to return a non-empty result. Antoine, what do you think of this? ---------- nosy: +pitrou _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15546> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com