New submission from Takeshi Yoshino <tyosh...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue12050>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to