[Python-Dev] Re-raise in absence of an "active" exception

Phillip J. Eby pje at telecommunity.com
Sat Jun 26 11:14:07 EDT 2004

At 02:20 PM 6/26/04 +0200, Martin v. Löwis wrote:
>Phillip J. Eby wrote:
>>> >>> try:
>>>..   1/0
>>>.. except:
>>>..   pass
>>> >>> raise
>>>Traceback (most recent call last):
>>>   File "<stdin>", line 1, in ?
>>>TypeError: exceptions must be classes, instances, or strings 
>>>(deprecated), not NoneType
>>>Here, the re-raise doesn't find an exception anymore, even
>>>though non has been raised...
>>Isn't each statement/block in the interactive interpreter run in a new frame?
>Yes, but why does that matter? If the language spec says
>"the exception stays until the next exception is raised", then
>the interpreter doesn't conform to the language spec, and has
>a bug.

I thought the spec was that exceptions are active for the life of a frame's 
execution.  That's probably my projection of the implementation onto an 
ambiguous phrase in the spec, though.

Nonetheless, I think that the ambiguity can and should be resolved by 
defining "active in the current scope" to mean, "caught by an exception 
handler in the current frame or one of its parents".  This explanation 
should probably be added to the section on "Exceptions", and 
cross-referenced from the section on "raise".

Is there consensus such that I should make these changes to the spec?

More information about the Python-Dev mailing list