Issue 654421: gzip shouldn't ValueError on corruptfile (original) (raw)

Issue654421

Created on 2002-12-16 06:39 by donut, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
gzip.py.ValueError.patch donut,2002-12-16 06:40 replace ValueError with IOError on corrupt files
Messages (3)
msg42005 - (view) Author: Matthew Mueller (donut) Date: 2002-12-16 06:39
Currently the gzip module will raise a ValueError if the file was corrupt (bad crc or bad size), but this is IMHO bad because it means you can't substitute a GzipFile for a regular file without the risk of exceptions breaking out of the code. (And you don't want to catch ValueError since it might hide coding errors). The docs say ValueError is "Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError". I can't see how that applies to reading a corrupt file. IOError is probably the correct exception, because it is what code will already be looking for, and because even if technically there wasn't an actual io error, from the point of view of the code, trying to read a corrupt file is like an io error.
msg42006 - (view) Author: Matthew Mueller (donut) Date: 2002-12-16 06:40
Logged In: YES user_id=65253 Remembered to click the checkbox for attaching a file.
msg42007 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-02-05 21:41
Logged In: YES user_id=11375 I'll buy that logic. Checked in as rev. 1.38 of gzip.py.
History
Date User Action Args
2022-04-10 16:06:02 admin set github: 37615
2002-12-16 06:39:23 donut create