Message2593
I'm not sure if this is just an undocumented limitation or a genuine bug. I'm using python 1.5.2 on winNT.
A single decompress of a large amount (16K+) of compressed data that has been sync-flushed fails to produce all the data up to the sync-flush. The data remains inside the decompressor untill further compressed data or a final flush is issued. Note that the 'unused_data' attribute does not show that there is further data in the decompressor to process (it shows '').
A workaround is to decompress the data in smaller chunks. Note that compressing data in smaller chunks is not required, as the problem is in the decompressor, not the compressor.
The following code demonstrates the problem, and raises an exception when the compressed data reaches 17K;
from zlib import *
from random import *
# create compressor and decompressor
c=compressobj(9)
d=decompressobj()
# try data sizes of 1-63K
for l in range(1,64):
# generate random data stream
a=''
for i in range(l*1024):
a=a+chr(randint(0,255))
# compress, sync-flush, and decompress
t=d.decompress(c.compress(a)+c.flush(Z_SYNC_FLUSH))
# if decompressed data is different to input data, barf,
if len(t) != len(a):
print len(a),len(t),len(d.unused_data)
raise error
|
|
Date |
User |
Action |
Args |
2007-08-23 13:52:21 | admin | link | issue224981 messages |
2007-08-23 13:52:21 | admin | create | |
|