How to determine what exceptions a method might raise?
Duncan Booth
duncan.booth at invalid.invalid
Wed Jan 17 04:33:17 EST 2007
"George Sakkis" <george.sakkis at gmail.com> wrote:
> As for the OP's question, since file is a fixed builtin, I think it
> should be possible to know all the possible exceptions that can be
> raised; I'm not sure if it's clearly documented though.
Just calling 'file' the most obvious exceptions it can raise are:
IOError
MemoryError
ValueError
I'm not sure if it can return UnicodeDecodeError, it looks as though it may
be possible on windows, but I couldn't trigger it.
Assigning the result to a variable can of course raise absolutely any
exception. That's the main problem: just because a C function raises only a
few different exceptions doesn't mean that the line of code calling it
cannot generate a host more.
More information about the Python-list
mailing list