This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: gzip._GzipReader should only throw BadGzipFile errors
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rhpvorderman
Priority: normal Keywords:

Created on 2021-03-25 08:24 by rhpvorderman, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg389494 - (view) Author: Ruben Vorderman (rhpvorderman) * Date: 2021-03-25 08:24
This is properly documented: https://docs.python.org/3/library/gzip.html#gzip.BadGzipFile . 

It now hrows EOFErrors when a stream is truncated. But this means that upstream both BadGzipFile and EOFError need to be catched in the exception handling when opening a gzip file for reading. When a gzip file is truncated it is also a "bad gzip file" in my opinion, so there is no reason to have an extra class of errors.
Also it throws zlib.error's when zlib craches for some reason. This means there is some corruption in the raw deflate block. Well that means it is a "bad gzip file" as well and the error message should reflect that. 

This won't break people's code. If they are already catching EOFError zlib.error and BadGzipFile it changes nothing. If they only catch BadGzipFile, they will have less annoying errors that pop through.

I can make the PR, but of course not without any feedback. I am curious what other people think.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87787
2021-03-25 08:25:21rhpvordermansettype: behavior
2021-03-25 08:24:44rhpvordermancreate