Issue1191043
Created on 2005-04-27 14:34 by catlee, last changed 2005-08-21 14:19 by georg.brandl. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg25148 - (view) | Author: Chris AtLee (catlee) | Date: 2005-04-27 14:34 | |
The following code:
echo -n Testing123 | bzip2 > test.bz2
python -c "import bz2; lines =
bz2.BZ2File('test.bz2').readlines()"
produces this output:
Traceback (most recent call last):
File "<string>", line 1, in ?
RuntimeError: wrong sequence of bz2 library commands used
Tested on Python 2.4.1 (debian unstable - April 1
2005), and Python 2.3.5 (debian unstable - May 26 2005)
|
|||
| msg25149 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2005-04-28 07:06 | |
Logged In: YES user_id=80475 The looks like correct behavior to me. The test.bz2 file is not in a valid bz2 format. I suspect that you've misread the BZ2File API which is intended for reading and writing uncompressed data to and from a file in a bz2 format (where the data is stored in compressed form). If this interpretation of the bug report is correct, please mark as not-a-bug and close. |
|||
| msg25150 - (view) | Author: Chris AtLee (catlee) | Date: 2005-04-28 12:00 | |
Logged In: YES
user_id=186532
How is test.bz2 not a valid bz2 file? The command line tool
"bzcat" or "bunzip2" can operate properly on it. Using
BZ2File("test.bz2").read() works properly, it's just the
readlines() call that breaks.
Try this out:
import bz2
bz2.BZ2File("test.bz2","w").write("testing123")
# This works fine
assert bz2.BZ2File("test.bz2").read() == "testing123"
# This raises a RuntimeError
assert bz2.BZ2File("test.bz2").readlines() == ["testing123"]
|
|||
| msg25151 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2005-04-28 12:14 | |
Logged In: YES user_id=80475 Okay, I see. Will look into it. |
|||
| msg25152 - (view) | Author: A.M. Kuchling (akuchling) * ![]() |
Date: 2005-06-14 14:55 | |
Logged In: YES user_id=11375 Calling .readline() works fine, though. The problem wasn't apparent with a quick look at the readlines() code. |
|||
| msg25153 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2005-08-21 12:03 | |
Logged In: YES user_id=80475 Reinhold, do you want to take this one? |
|||
| msg25154 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2005-08-21 14:19 | |
Logged In: YES user_id=1188172 Fixed, also for xreadlines(). Problem was that the code, if there were no newlines in a chunk read from the file, assumed that the buffer was too small. Modules/bz2module.c r1.25 Lib/test/test_bz2.py r1.18 Please review the fix! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2005-04-27 14:34:37 | catlee | create | |
