Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38782
| From | Marc Christiansen <usenet@solar-empire.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Generate 16+MAX_WBITS decompressable data |
| Date | 2013-02-12 21:39 +0100 |
| Message-ID | <jtlqu9-bcc.ln1@pluto.solar-empire.de> (permalink) |
| References | <kfddp5$fho$1@ger.gmane.org> <mailman.1705.1360682882.2939.python-list@python.org> |
Terry Reedy <tjreedy@udel.edu> wrote:
> On 2/12/2013 7:47 AM, Fayaz Yusuf Khan wrote:
>> dcomp = zlib.decompressobj(16+zlib.MAX_WBITS)
>
> Since zlib.MAX_WBITS is the largest value that should be passed (15),
> adding 16 makes no sense. Since it is also the default, there is also no
> point in providing it explicitly. "Its absolute value should be between
> 8 and 15 for the most recent versions of the zlib library".
The above code uses a feature of the zlib library which isn't really
widely known.
From http://www.zlib.net/manual.html#Advanced (inflateInit2):
windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic
header detection, or add 16 to decode only the gzip format (the zlib
format will return a Z_DATA_ERROR).
>> How do I generate the chunk here? From what I've been trying I'm getting
>> this exception:
>>>>> import zlib
>>>>> zlib.compress('hello')
>> 'x\x9c\xcbH\xcd\xc9\xc9\x07\x00\x06,\x02\x15'
>>>>> zlib.decompress(_, 16+zlib.MAX_WBITS)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> zlib.error: Error -3 while decompressing data: incorrect header check
Try using a compressobj with 24 <= wbits < 32. It should work, but I
didn't try.
Marc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Generate 16+MAX_WBITS decompressable data Terry Reedy <tjreedy@udel.edu> - 2013-02-12 10:27 -0500
Re: Generate 16+MAX_WBITS decompressable data Marc Christiansen <usenet@solar-empire.de> - 2013-02-12 21:39 +0100
Re: Generate 16+MAX_WBITS decompressable data Fayaz Yusuf Khan <fayaz@dexetra.com> - 2013-02-13 10:48 +0530
Re: Generate 16+MAX_WBITS decompressable data Terry Reedy <tjreedy@udel.edu> - 2013-02-13 01:30 -0500
csiph-web