[Python-Dev] Re-raise in absence of an "active" exception
Jeremy Hylton
jeremy at alum.mit.edu
Fri Jun 25 07:10:47 EDT 2004
On Fri, 2004-06-25 at 05:20, Alex Martelli wrote:
> On 2004 Jun 24, at 17:15, Jeremy Hylton wrote:
>
> > On Mon, 2004-06-21 at 01:22, "Martin v. Löwis" wrote:
> >> "If no exception is active in the current scope, an exception is
> >> raised
> >> indicating this error."
> >>
> >> "This" error probably being "no active exception", not "exception must
> >> not be NoneType".
> >
> > We can determine statically whether an exception would active in the
> > current scope, right? If the raise does not occur within an except
> > handler, then there is no active exception in the current scope. I
> > think it should be a SyntaxError.
>
> Isn't the "raise" allowed to occur in a function that may be _called
> from_ an except handler? E.g.:
>
> >>> def foo():
> ... print "do something here"
> ... raise
> ...
> >>> try: 1/0
> ... except Exception: foo()
The definition of what it means for an exception to be "active" in a
scope needs to be clarified. The language reference doesn't appear to
define what that means, so I took a narrow reading. I think the code
you mention later in your post is code I wrote :-).
Jeremy
More information about the Python-Dev
mailing list