[Patches] [ python-Patches-654421 ] gzip shouldn't ValueError on corruptfile
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 15 Dec 2002 22:40:32 -0800
Patches item #654421, was opened at 2002-12-15 23:39
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=654421&group_id=5470
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthew Mueller (donut)
Assigned to: Nobody/Anonymous (nobody)
Summary: gzip shouldn't ValueError on corruptfile
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Matthew Mueller (donut)
Date: 2002-12-15 23:40
Message:
Logged In: YES
user_id=65253
Remembered to click the checkbox for attaching a file.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=654421&group_id=5470