[ python-Bugs-1191043 ] bz2 RuntimeError when decompressing file
SourceForge.net
noreply at sourceforge.net
Thu Apr 28 14:14:28 CEST 2005
Bugs item #1191043, was opened at 2005-04-27 09:34
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1191043&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris AtLee (catlee)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: bz2 RuntimeError when decompressing file
Initial Comment:
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)
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2005-04-28 07:14
Message:
Logged In: YES
user_id=80475
Okay, I see. Will look into it.
----------------------------------------------------------------------
Comment By: Chris AtLee (catlee)
Date: 2005-04-28 07:00
Message:
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"]
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-04-28 02:06
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1191043&group_id=5470
More information about the Python-bugs-list
mailing list