[issue8397] BZ2File doesn't protect against mixed iterator and read usage
Alex Stapleton
report at bugs.python.org
Wed Apr 14 15:01:16 CEST 2010
New submission from Alex Stapleton <alex.stapleton at gmail.com>:
Normal files throw exceptions if you mix methods.
>>> f = open("words")
>>> for l in f:
... break
...
>>> f.tell()
8192L
>>> f.readline()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Mixing iteration and read methods would lose data
BZ2Files silently do the wrong thing. (Output is a coincidence. Honest!)
>>> import bz2
>>> f = bz2.BZ2File("words.bz2")
>>> for l in f:
... break
...
>>> f.tell()
8192L
>>> f.readline()
'lose\n'
Expected behaviour is for it to throw a ValueError like normal file objects.
----------
components: None
messages: 103126
nosy: Alex.Stapleton
severity: normal
status: open
title: BZ2File doesn't protect against mixed iterator and read usage
versions: Python 2.5, Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8397>
_______________________________________
More information about the Python-bugs-list
mailing list