t.append (buf)
if len (t) > 0:
break
- raise
+ raise
+ except ReadError: # gzip troubles
+ if self.tolerance == TOLERANCE_RESCUE:
+ if len (buf) > 0:
+ t.append (buf)
+ if len (t) > 0:
+ break
+ raise
except EndOfFile:
# happens at the end of the file
pass
if self.tolerance == TOLERANCE_STRICT:
raise
self.encryption.drop ()
- if good_crypto == 0:
- raise
- # this may occur at any of the three crypto operations above.
- # some objects did validate; discard all data after it; next
- # call will start with the bad object and error out immediately
- self.buf = b"".join (t [good_crypto:])
- return b"".join (t [:good_crypto])
+ if self.tolerance == TOLERANCE_RECOVER:
+ if good_crypto == 0:
+ raise
+ # this may occur at any of the three crypto operations above.
+ # some objects did validate; discard all data after it; next
+ # call will start with the bad object and error out immediately
+ self.buf = b"".join (t [good_crypto:])
+ return b"".join (t [:good_crypto])
+ elif self.tolerance == TOLERANCE_RESCUE:
+ # keep what we have so far despite the finalization issue
+ t.append (buf)
+ c += len (buf)
+ break
+ else:
+ raise RuntimeError("internal error: bad tolerance level")
if not buf: ## XXX stream terminated prematurely; this should be an error
break