File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,6 @@ cdef class Compress:
469
469
return b" "
470
470
elif mode == zlib.Z_FINISH:
471
471
self .stream.flush = FULL_FLUSH
472
- self .stream.end_of_stream = 1
473
472
elif mode == zlib.Z_FULL_FLUSH:
474
473
self .stream.flush = FULL_FLUSH
475
474
elif mode == zlib.Z_SYNC_FLUSH:
@@ -493,10 +492,16 @@ cdef class Compress:
493
492
# the data is appended to a list.
494
493
# TODO: Improve this with the buffer protocol.
495
494
out.append(self .obuf[:self .obuflen - self .stream.avail_out])
496
- if self .stream.internal_state.state != ZSTATE_END and mode == zlib.Z_FINISH:
497
- continue
498
- elif self .stream.avail_in == 0 :
499
- break
495
+
496
+ if self .stream.avail_out != 0 : # All input is processed and therefore all output flushed.
497
+ if self .stream.internal_state.state != ZSTATE_END and mode == zlib.Z_FINISH:
498
+ # If mode ==zlib.Z_FINISH we do one more round to finish the stream.
499
+ self .stream.end_of_stream = 1
500
+ continue
501
+ else :
502
+ break
503
+ if self .stream.avail_in != 0 :
504
+ raise AssertionError (" There should be no available input after flushing." )
500
505
return b" " .join(out)
501
506
502
507
cdef class Decompress:
You can’t perform that action at this time.
0 commit comments