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 Takeshi.Yoshino
Recipients Takeshi.Yoshino
Date 2011-05-10.10:44:13
SpamBayes Score 3.861899e-06
Marked as misclassified No
Message-id <1305024254.99.0.898091507318.issue12050@psf.upfronthosting.co.za>
In-reply-to
Content
http://docs.python.org/library/zlib.html
says
"If max_length is not supplied then the whole input is decompressed, and unconsumed_tail is an empty string."

However, if there's preceding decompress call with max_length specified, unconsumed_tail will not be empty.

----
import zlib

c = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -zlib.MAX_WBITS)
compressed = c.compress('abc')
compressed += c.flush(zlib.Z_SYNC_FLUSH)

d = zlib.decompressobj(-zlib.MAX_WBITS)
original = d.decompress(data, 1)
original += d.decompress(d.unconsumed_tail)
print "%r" % d.unconsumed_tail
----

Result is

----
'\x06\x00\x00\x00\xff\xff'
----

Document or code should be fixed.
History
Date User Action Args
2011-05-10 10:44:15Takeshi.Yoshinosetrecipients: + Takeshi.Yoshino
2011-05-10 10:44:14Takeshi.Yoshinosetmessageid: <1305024254.99.0.898091507318.issue12050@psf.upfronthosting.co.za>
2011-05-10 10:44:13Takeshi.Yoshinolinkissue12050 messages
2011-05-10 10:44:13Takeshi.Yoshinocreate