[issue20856] bz2.peek always peeks all the remaining bytes ignoring n argument

2014-03-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Because it is unspecified in io.BufferedReader.peek() and in many classes implemented the io.BufferedReader interface. .. method:: peek([size]) Return bytes from the stream without advancing the position. At most one single read on the raw st

[issue20856] bz2.peek always peeks all the remaining bytes ignoring n argument

2014-03-06 Thread Vajrasky Kok
Vajrasky Kok added the comment: Just curious, why the exact number of bytes returned is unspecified in bz2 (in other words, n argument is ignored)? gzip uses n argument. -- ___ Python tracker _

[issue20856] bz2.peek always peeks all the remaining bytes ignoring n argument

2014-03-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is documented behavior. .. method:: peek([n]) Return buffered data without advancing the file position. At least one byte of data will be returned (unless at EOF). The exact number of bytes returned is unspecified. -- nosy:

[issue20856] bz2.peek always peeks all the remaining bytes ignoring n argument

2014-03-06 Thread Vajrasky Kok
New submission from Vajrasky Kok: # Bug demo TEXT_LINES = [ b'cutecat\n', b'promiscuousbonobo\n', ] TEXT = b''.join(TEXT_LINES) import bz2 filename = '/tmp/demo.bz2' with open(filename, 'wb') as f: f.write(bz2.compress(TEXT)) with bz2.BZ2File(filename) as bz2f: pdata = bz2f.peek(