@@ -120,16 +120,26 @@ def compressed_bytes_read(self):
120120 # until it is finished, to yield the actual number of compressed bytes
121121 # belonging to the decompressed object
122122 # We are using a custom zlib module for this, if its not present,
123- # we can only hope it works.
123+ # we try to put in additional bytes up for decompression if feasible
124+ # and check for the unused_data.
125+
124126 # Only scrub the stream forward if we are officially done with the
125127 # bytes we were to have.
126- if self ._br == self ._s and hasattr ( self . _zip , 'status' ) and self ._zip .status == zlib . Z_OK :
128+ if self ._br == self ._s and not self ._zip .unused_data :
127129 # manipulate the bytes-read to allow our own read method to coninute
128130 # but keep the window at its current position
129131 self ._br = 0
130- while self ._zip .status == zlib .Z_OK :
131- self .read (mmap .PAGESIZE )
132- # END scrub-loop
132+ if hasattr (self ._zip , 'status' ):
133+ while self ._zip .status == zlib .Z_OK :
134+ self .read (mmap .PAGESIZE )
135+ # END scrub-loop custom zlib
136+ else :
137+ # pass in additional pages, until we have unused data
138+ while not self ._zip .unused_data and self ._cbr != len (self ._m ):
139+ self .read (mmap .PAGESIZE )
140+ # END scrub-loop default zlib
141+ # END handle stream scrubbing
142+
133143 # reset bytes read, just to be sure
134144 self ._br = self ._s
135145 # END handle stream scrubbing
@@ -231,8 +241,6 @@ def read(self, size=-1):
231241 self ._cbr += len (indata ) - len (self ._zip .unconsumed_tail )
232242 self ._br += len (dcompdat )
233243
234- print size , self ._br , self ._cbr , len (indata ), self ._cws , self ._cwe , len (self ._zip .unused_data ), len (self ._zip .unconsumed_tail )
235-
236244 if dat :
237245 dcompdat = dat + dcompdat
238246
0 commit comments