Reporting important unhandled exceptions before they occur

Peter Hansen peter at engcorp.com
Tue Nov 4 10:55:29 EST 2003


Afanasiy wrote:
> 
> I recently decided it would be best for me to know about unhandled
> exceptions before they occur. I imagined some tool could check for this,
> possibly even an extreme mode of PyChecker. However, I found none.
> 
> I suppose, without much thought, that some tool could just list the last
> few levels in which an exception could be thrown but is not handled.
> 
> Does such a tool exist?
> 
> P.S. I do not need to be lectured on why you might think this is bad.

How about being lectured on why it's practically impossible for the
general case?  ;-)

(That is, given that Python is so dynamic, effectively any code called
can generate any one of a whole variety of errors, and static analysis
may be unable to tell you anything useful about it.  For example, an
exec statement can presumably raise any exception at all... )

If you can narrow down the scope of the problem, you might find a
solution, but to me it sounds like taking an idea from Java (where
everything has an explicitly defined set of possible exceptions)
and trying to apply it to an area where it just can't work.

-Peter




More information about the Python-list mailing list