Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38759
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Generate 16+MAX_WBITS decompressable data |
| Date | 2013-02-12 10:27 -0500 |
| References | <kfddp5$fho$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1705.1360682882.2939.python-list@python.org> (permalink) |
On 2/12/2013 7:47 AM, Fayaz Yusuf Khan wrote:
> I'm trying write unit-tests for some of my old code and have run into this
> piece of code.
>
> 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".
> chunk = ''.join(f.chunks())
> received_data = dcomp.decompress(chunk)
Since decompressobj is intended for data that will not all fit in memory
at once, and since chunk does, just use zlib.decompress(chunk)
> 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
You asked for an internal buffer of 2**31 = 2 gigabytes.
> zlib.decompress without the second argument works, but I can't really go
> ahead into my project file and remove it.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — 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