zlib problems with Python 2.0

Peter van der Kamp vdkamp at inter.nl.net
Fri Aug 24 16:24:27 CEST 2001


Hello,

> Another thought just occurred to me - you should be opening the files in
> binary mode: 'wb' for write and 'rb' for read.

Thanks to answers on this group I was able to solve
the zlib problems with Python 2.0. Two things
contributed to the problem.
First, I didn't open the file to which I wrote the
compressed chunks of text in binary mode. Before
posting the problem I had tried the
binary mode but without success and that's were the
second reason appears.
After writing a chunk of compressed text I added the
length of this chunk + 1 to the variable containing
the start position, thus obtaining the start position of the
next chunk (I need the start position for retrieval
purposes). Adding the extra 1 proved to be wrong.
Adding the length only was OK. Everything now works as expected.

Peter van der Kamp



More information about the Python-list mailing list