[New-bugs-announce] [issue12050] unconsumed_tail of zlib.Decompress is not always cleared on decompress() call

Takeshi Yoshino report at bugs.python.org
Tue May 10 12:44:14 CEST 2011


New submission from Takeshi Yoshino <tyoshino at google.com>:

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.

----------
components: Library (Lib)
messages: 135697
nosy: Takeshi.Yoshino
priority: normal
severity: normal
status: open
title: unconsumed_tail of zlib.Decompress is not always cleared on decompress() call
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12050>
_______________________________________


More information about the New-bugs-announce mailing list