zlib decode fails with -5

Paul Watson pwatson at redlinepy.com
Thu Sep 29 16:56:34 EDT 2005


"ncf" <nothingcanfulfill at gmail.com> wrote in message 
news:1127877052.360470.227960 at z14g2000cwz.googlegroups.com...
>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





More information about the Python-list mailing list