zlib decode fails with -5

P

Paul Watson

Traceback (most recent call last):
File "<string>", line 20, in ?
File "c:\Python24\lib\encodings\zlib_codec.py", line 43, in zlib_decode
output = zlib.decompress(input)
zlib.error: Error -5 while decompressing data

The -5 error appears to be a Z_BUF_ERROR from looking at the manual at
http://www.zlib.net/

The original data was 50K. It compressed to 30K. When I try to decompress,
this error occurs.

I have done this successfully on 150K of data, so I do not know why it would
be a space issue.

Any ideas or suggestions?
 
N

ncf

I don't mean this harshly, but have you tried recompressing the data to
see if you may have had a bad data set?

If it still fails, then I'm really not sure why/how zlib decides that
there isn't enough room in the output buffer.
"Z_BUF_ERROR if there was not enough room in the output buffer"

Sorry I couldn't be of much assistance on this matter.
-Wes
 
P

Paul Watson

ncf said:
I don't mean this harshly, but have you tried recompressing the data to
see if you may have had a bad data set?

If it still fails, then I'm really not sure why/how zlib decides that
there isn't enough room in the output buffer.
"Z_BUF_ERROR if there was not enough room in the output buffer"

Sorry I couldn't be of much assistance on this matter.
-Wes

Ok. The answer seems to be that sys.stdin.read() on Windows appears to be
doing newline massaging. I had to set the mode to binary. If msvcrt fails
to load, then it is not a Windows machine and should do the right thing
anyway.

try
import msvcrt, os
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
except:
pass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top