class EncryptionError(TarError):
"""Exception for error during decryption."""
pass
+class EndOfFile(Exception):
+ """Signal end of file condition when they’re not an error."""
#---------------------------
# internal stream interface
"""
self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
- # taken from gzip.GzipFile with some alterations
read2 = self.__read(2)
+ if read2 == b"":
+ raise EndOfFile ("_init_read_gz(): read returned zero bytes at pos "
+ "%d" % self.fileobj.tell())
+ # taken from gzip.GzipFile with some alterations
if read2 != GZ_MAGIC_BYTES:
raise ReadError("not a gzip file")
self.close(close_fileobj=False)
try:
self._init_read_gz()
- except:
+ except EndOfFile:
# happens at the end of the file
pass
self.crc = self.zlib.crc32(b"") & 0xFFFFffff