Python gzip BadGzipFile method














































Python gzip BadGzipFile method



Python gzip BadGzipFile method

Description

exception gzip.BadGzipFile
This method of 'gzip' is an exception which is raised for an invalid 'gzip files'. It inherits 'OSError'. 'EOFError' and 'zlib.error' can also be raised for invalid gzip files.

Note

'OSError' is raised when a system function returns a system-related error, including I/O failures.
'EOFError' is raised when the 'input()' function hits an end-of-file condition (EOF) without reading any data.
'zlib.error' is raised on compression and decompression errors.

Example

import gzip
def
inflate(data: bytes) -> bytes:
try:
return gzip.decompress(data)
except (gzip.BadGzipFile, zlib.error):
pass


Comments