[Tutor] catching any exception?

Jeff Shannon jeff@ccvcorp.com
Fri Nov 15 13:03:14 2002


"Chermside, Michael" wrote:

> > Apparently although "Exception" is the parent of all
> > exceptions, it is not an exception itself, so this never matched.
>
> Actually, I don't think that's true. Let me run a quick test:

Indeed, neither part of the statement is completely true.  "Exception" is
indeed an exception, and it is *intended* to be the parent of all
exceptions... but class-based exceptions have only been around since (I
think) Python 2.0, and some third-party modules still use the older,
string-based exceptions, which obviously cannot inherit from Exception.

I haven't analyzed the O.P.'s code enough to have any clue how likely it is
that this is the problem in this case, but it's a possibility.  In the
meantime, as someone else suggested, the traceback module should be able to
grab exception information when using a bare except, which should let you
solve your original problem.

Jeff Shannon
Technician/Programmer
Credit International