False exceptions?" (was Re: theme of the week: tools

David Bolen db3l at fitlinxx.com
Tue Sep 28 18:49:27 CEST 2004


Richie Hindle <richie at entrian.com> writes:

> [Stephan]
> > The "false exceptions" thing is a technical limitation of detecting
> > whether or not an exception is going to lead to program termination at the
> > moment it is raised, rather than later when exiting the program.  We go up
> > the stack to inspect Python byte code, and since we can't see into C/C++
> > object code we sometimes get it wrong.
> 
> Thanks for this explanation - very interesting.  I'm a bit confused as to why
> you do this, though.  Assuming an exception "is going to lead to program
> termination", trapping it at the point it's raised is only one instruction
> away from trapping at the point it causes termination (via sys.excepthook).
(...)
> Is that really the only reason you've implemented this feature, or am I
> missing something?

You're assuming that it's all Python code up the stack until the final
exception handling.  If there's an extension module in the way, you
lose the ability to get at the information, and if that extension
module decides to absorb the error, then there's no longer a chance to
catch it.  Unfortunately, it's the cases where the extension module
silently absorbs the exception when things are working properly that
Wing can't detect and would flag the exception anyway.

-- David



More information about the Python-list mailing list