This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年04月14日 13:01 by Alex.Stapleton, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| bziter.patch | pitrou, 2010年08月01日 19:33 | |||
| Messages (4) | |||
|---|---|---|---|
| msg103126 - (view) | Author: Alex Stapleton (Alex.Stapleton) | Date: 2010年04月14日 13:01 | |
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.
|
|||
| msg112327 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年08月01日 13:57 | |
Well I'm not the bz2 maintainer but I could take a look. The BZ2File implementation is generally a straight ripoff of the 2.x file object, with (de)compression calls added where necessary. I guess the ripoff was a one-shot effort and subsequent maintenance wasn't done. It makes it quite a bit alien in the 3.x IO landscape, but until someone decides to rewrite it we'll have to live with that. |
|||
| msg112372 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年08月01日 19:33 | |
Here is a patch for py3k. |
|||
| msg112378 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年08月01日 20:17 | |
Fixed in r83440 (py3k), r83441 (3.1), r83442 (2.7), r83443 (2.6). |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:59 | admin | set | github: 52644 |
| 2010年08月01日 20:17:42 | pitrou | set | status: open -> closed resolution: fixed messages: + msg112378 stage: resolved |
| 2010年08月01日 19:33:07 | pitrou | set | files:
+ bziter.patch nosy: + georg.brandl messages: + msg112372 keywords: + patch |
| 2010年08月01日 13:57:27 | pitrou | set | messages: + msg112327 |
| 2010年08月01日 07:37:18 | georg.brandl | set | priority: normal -> high assignee: pitrou nosy: + pitrou versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.5 |
| 2010年04月14日 13:01:14 | Alex.Stapleton | create | |