Background
I have inherited a code base with many suggestions try ... except:
. Most of them are too wide, and to make it painful to debug. I went through and changed each to the most reasonable form, which usually involves the removal or indication of exception (s).
Problem
But I'm a little puzzled by this:
try:
with open(self.session_filename, "rb") as f:
data = cPickle.loads(zlib.decompress(f.read()))
except:
return
I want to handle exceptions specifically, but Python docs on Pickle say:
pickle.UnpicklingError exception
This exception occurs when a problem occurs with the object. Note that other exceptions may also be unickling, including (but not necessarily limited to) AttributeError
, EOFError
, ImportError
and IndexError
.
Translation: a method can throw something!
, , , .
, :
, .