[issue16350] zlib.Decompress.decompress() after EOF discards existing value of unused_data

Nadeem Vawda report at bugs.python.org
Sun Oct 28 17:25:19 CET 2012


New submission from Nadeem Vawda:

>From issue 5210:

amaury.forgeotdarc wrote:
> Hm, I tried a modified version of your first test, and I found another
> problem with the current zlib library;
> starting with the input:
> x = x1 + x2 + HAMLET_SCENE    # both compressed and uncompressed data
>
> The following scenario is OK:
> dco.decompress(x) # returns HAMLET_SCENE
> dco.unused_data   # returns HAMLET_SCENE
>
> But this one:
> for c in x:
>     dco.decompress(x) # will return HAMLET_SCENE, in several pieces
> dco.unused_data   # only one character, the last of (c in x)!
>
> This is a bug IMO: unused_data should accumulate all the extra uncompressed 
> data.

Ideally, I would prefer to raise an EOFError if decompress() is called
after end-of-stream is reached (for consistency with BZ2Decompressor).
However, accumulating the data in unused_data is closer to being backward-
compatible, so it's probably the better approach to take.

----------
components: Library (Lib)
files: zlib_unused_data_test.py
messages: 174056
nosy: amaury.forgeotdarc, nadeem.vawda
priority: normal
severity: normal
stage: needs patch
status: open
title: zlib.Decompress.decompress() after EOF discards existing value of unused_data
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file27767/zlib_unused_data_test.py

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


More information about the Python-bugs-list mailing list