New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odd behaviour with zlib.decompressobj optional parameter "wbits" #51440
Comments
>>> import zlib
>>> help(zlib.decompressobj)
Help on built-in function decompressobj in module zlib: decompressobj(...)
decompressobj([wbits]) -- Return a decompressor object.
I experimented with this parameter and by trial and >>> 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
Now to the odd part. Let us create another decompressobj without any
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 Either there is no need to expose this as a parameter |
The decompressor can't have a window size smaller than the size used to Still, the docs must be improved, e.g. compressobj() has more parameters |
Ok, so you think a documentation update is enough ? Thanks. |
wbits described further in rev78561. Thanks for your suggestion! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: