report at bugs
Aug 3, 2012, 3:27 PM
Post #5 of 16
Nadeem Vawda added the comment:
[issue15546] Iteration breaks with bz2.open(filename,'rt')
[In reply to]
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?
Python tracker <report [at] bugs>
Python-bugs-list mailing list