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

"Martin v. Löwis" martin at v.loewis.de
Mon Jun 28 01:17:08 EDT 2004


Greg Ewing wrote:
>>I'm actually surprised that the exception is cleared when the
>>function that has the exception handler completes.
> 
> 
> I think it's probably when the "except" clause of the
> exception handler completes, not the function.

See for yourself:

def f():
   try:
     raise Exception, "Hello"
   except:
     pass
   raise

f()

gives

Traceback (most recent call last):
   File "c.py", line 8, in ?
     f()
   File "c.py", line 3, in f
     raise Exception, "Hello"
Exception: Hello

Regards,
Martin




More information about the Python-Dev mailing list