[issue20856] bz2.peek always peeks all the remaining bytes ignoring n argument
Vajrasky Kok
report at bugs.python.org
Thu Mar 6 09:56:39 CET 2014
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(n=7)
print(pdata)
It outputs b'cutecat\npromiscuousbonobo\n', not b'cutecat'.
Here is the patch to fix the bug.
----------
components: Library (Lib)
files: use_n_argument_in_peek_bz2.patch
keywords: patch
messages: 212796
nosy: nadeem.vawda, vajrasky
priority: normal
severity: normal
status: open
title: bz2.peek always peeks all the remaining bytes ignoring n argument
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file34291/use_n_argument_in_peek_bz2.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20856>
_______________________________________
More information about the Python-bugs-list
mailing list