This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pythonhacker
Recipients pythonhacker
Date 2009-10-23.13:40:55
SpamBayes Score 8.1656903e-14
Marked as misclassified No
Message-id <1256305257.34.0.885450394278.issue7191@psf.upfronthosting.co.za>
In-reply-to
Content
>>> import zlib
>>> help(zlib.decompressobj)
Help on built-in function decompressobj in module zlib:

decompressobj(...)
    decompressobj([wbits]) -- Return a decompressor object.

    Optional arg wbits is the window buffer size.

I experimented with this parameter and by trial and
error found out that it accepts only values from 8 to
15 inclusive. 

>>> z=zlib.decompressobj(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Invalid initialization option
>>> z=zlib.decompressobj(7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Invalid initialization option
>>> z=zlib.decompressobj(16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Invalid initialization option

>>> z1=zlib.decompressobj(8)
>>> z2=zlib.decompressobj(15)

Now to the odd part. Let us create another decompressobj without any
parameter. 

>>> z3=zlib.decompressobj()

Now compress some data.
>>> c=zlib.compress("This is a medium line of text")

Decompress with z2 works fine.
>>> z3.decompress(c)
b'This is a medium line of text'

Decompress with z2 is also fine.

>>> z2.decompress(c)
b'This is a medium line of text'

However with z1 it fails.
>>> z1.decompress(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
zlib.error: Error -3 while decompressing: invalid window size

In fact, only the optional value of 15 seems to work 
for wbits, every other legal value (8-14) fails giving
the same error. I tried this with other random strings
with same effect.

Either there is no need to expose this as a parameter
or there could be a bug with how this parameter is used,
which has to be fixed. In either case, documentation
on this parameter has to be improved and legal range
of values should be provided.
History
Date User Action Args
2009-10-23 13:40:57pythonhackersetrecipients: + pythonhacker
2009-10-23 13:40:57pythonhackersetmessageid: <1256305257.34.0.885450394278.issue7191@psf.upfronthosting.co.za>
2009-10-23 13:40:56pythonhackerlinkissue7191 messages
2009-10-23 13:40:55pythonhackercreate