[Python-Dev] Question on bz2 codec. Is this a bug?
chris at subtlety.com
Thu Sep 30 01:06:06 CEST 2010
On Wed, Sep 29, 2010 at 5:59 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Le mercredi 29 septembre 2010 à 17:41 -0400, Chris Bergstresser a
> écrit :
>> On Wed, Sep 29, 2010 at 5:23 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> > Anyway, the obvious way to write line-by-line to a bz2 file is to use
>> > the BZ2File class!
>> The BZ2File class does not allow you to open a file for appending.
>> Using the incremental encoder does work,
> In what sense? Do you mean it adds a new bz2 stream at the end of the
> existing file?
Yes. If you open an existing bz2 file for appending and use the
incremental encoder to encode the data you write to it, you end up
with a single file containing two separate bz2 compressed blocks of
data. The bunzip2 program handles multiple streams in a single file
correctly, and there's a bug open (complete with working patch) in the
Python tracker to handle them as well.
More information about the Python-Dev