From: Matthew Brett on
Hi,

I sorry if this is a bad place to ask, but I wanted to find out if the
behavior I'm seeing is a bug.

I maintain scipy's matlab file readers, and I came across a zlib
compressed string that causes a zlib error on decompression, but only
with zlib.decompress, not zlib.decompressobj.

I saved the original compressed string as a binary file at
http://dl.dropbox.com/u/794947/mat.bin

Now if I do:

import zlib
data = open('mat.bin', 'rb').read()
out = zlib.decompress(data)

I get an error : Error -5 while decompressing data)

If instead I do this:

out = zlib.decompressobj().decompress(data)

I get a usable uncompressed string. I was expecting these two calls
to do the same thing. Is that expectation right? If not, is there
somewhere I could find out why?

Thanks a lot,

Matthew
From: Matthew Brett on
Hi,

Thanks for the reply.

> > If instead I do this:
>
> > out = zlib.decompressobj().decompress(data)
>
> How about:
>
> d = zlib.decompressobj()
> out = d.decompress(data) + d.flush()

Do you mean, that you would then expect the decompressobj method to
fail as well?

But, no, d.flush() returns the empty string after decompressing
``data``.

Thanks again,

Matthew

From: Antoine Pitrou on
On Sun, 9 May 2010 09:25:16 -0700 (PDT)
Matthew Brett <matthew.brett(a)gmail.com> wrote:
> > How about:
> >
> > d = zlib.decompressobj()
> > out = d.decompress(data) + d.flush()
>
> Do you mean, that you would then expect the decompressobj method to
> fail as well?

Yes.

> But, no, d.flush() returns the empty string after decompressing
> ``data``.

Hmm, then it's a bug. Can you report it to http://bugs.python.org ?

Thank you

Antoine.


From: Matthew Brett on
Hi,

> > Do you mean, that you would then expect the decompressobj method to
> > fail as well?
>
> Yes.
>
> > But, no, d.flush() returns the empty string after decompressing
> > ``data``.
>
> Hmm, then it's a bug. Can you report it tohttp://bugs.python.org?

I will - thanks for your advice,

Matthew