Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip._GzipReader should only throw BadGzipFile errors #87787

Open
rhpvorderman mannequin opened this issue Mar 25, 2021 · 1 comment
Open

gzip._GzipReader should only throw BadGzipFile errors #87787

rhpvorderman mannequin opened this issue Mar 25, 2021 · 1 comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rhpvorderman
Copy link
Mannequin

rhpvorderman mannequin commented Mar 25, 2021

BPO 43621
Nosy @rhpvorderman

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-03-25.08:24:44.466>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.7', 'library']
title = 'gzip._GzipReader should only throw BadGzipFile errors'
updated_at = <Date 2021-03-25.08:25:21.785>
user = 'https://github.com/rhpvorderman'

bugs.python.org fields:

activity = <Date 2021-03-25.08:25:21.785>
actor = 'rhpvorderman'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-03-25.08:24:44.466>
creator = 'rhpvorderman'
dependencies = []
files = []
hgrepos = []
issue_num = 43621
keywords = []
message_count = 1.0
messages = ['389494']
nosy_count = 1.0
nosy_names = ['rhpvorderman']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue43621'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

@rhpvorderman
Copy link
Mannequin Author

rhpvorderman mannequin commented Mar 25, 2021

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.

@rhpvorderman rhpvorderman mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 25, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: No status
Development

No branches or pull requests

0 participants