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

From: Richie Hindle (richie_at_entrian.com)
Date: 09/28/04


To: python-list@python.org
Date: Tue, 28 Sep 2004 15:35:30 +0100


[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).
When it hits sys.excepthook, it's still carrying all the stack frames that led
to its being thrown. If you make those stack frames available in the
debugger, you'd still be able to inspect the state of the code as it was when
the exception was raised. Nothing can have happened to change the state of
the program in the intervening... ah, OK, 'finally' blocks. 'Finally' blocks
will run between the exception being raised and sys.excepthook being called.
Is that really the only reason you've implemented this feature, or am I
missing something?

-- 
Richie Hindle
richie@entrian.com


Relevant Pages

  • Re: The origins of CL conditions system
    ... 'During the design of the exception handling mechanism, ... termination semantics or resumption semantics; ... even if you don't have resumption as ...
    (comp.lang.lisp)
  • Structured Exception Handling (was: Try Finally...)
    ... [MSDN: Structured Exception Handling] ... requires the execution of code outside the normal flow of control... ... whenever a guarded body of code is executed, a specified block of termination ... exception handler to handle the exception. ...
    (comp.lang.pascal.delphi.misc)
  • Re: My mistake (I think)
    ... On exception ... Call "XYZ" ... termination" indicates that your example above is permitted. ... "Wherever 'imperative-statement' appears in the general ...
    (comp.lang.cobol)
  • Re: opening files and code cleanup
    ... before program termination, then what you really need is *not* ... an exception handling mechanism, but a thing that allows you to ... I guess that depends on if the exception handling capability is required ...
    (comp.lang.fortran)
  • Re: False exceptions?" (was Re: theme of the week: tools
    ... > whether or not an exception is going to lead to program termination at the ... Richie Hindle ...
    (comp.lang.python)