[Stackless] A question about exceptions

Steve Holden steve at holdenweb.com
Fri Nov 24 19:47:24 CET 2006

I suppose it's required by a raise statement with no exception. This can 
be executed at any time after an exception is caught.Can't think of any 
other reason anyway.


Kristján V. Jónsson wrote:
> Well, Perhaps My question wasn't clear enough:
> def foo():
> 	try:
> 		1/0
> 	except ZeroDivisionError:
> 		HandleError()
> 		#sys.clear_error()  #this appears necessary
> 	#exception has been handled.
> 	import sys
> 	print sys.get_exc() #here we still get the exception.  Why?
> My question is more, why are we keeping the exception state around with the frame _after_ any handling has taken
> place?  If we want to examine the exception at some later date, we can store it using sys.get_exc() and do it
> excplicitly.  It seems strange to hang on to it after we have handled it, (in fact, requiring exc_clear() to get rid of the gunk sometimes)
> which is why I am asking if there is some obscure language design or implementation feature that requires it.
> K
>> -----Original Message-----
>> From: stacklesspython at dfackrell.mailshell.com 
>> [mailto:stacklesspython at dfackrell.mailshell.com] 
>> Sent: 24. nóvember 2006 16:26
>> To: Kristján V. Jónsson; stackless at stackless.com
>> Subject: Re: [Stackless] A question about exceptions
>> Kristján,
>> The state and frame are kept around for the handler.  Having 
>> the frame around allows you to use Python's incredible 
>> introspection ability to analyze the variables, call path, 
>> and so on.  Hope this helps.
>> Daniel Fackrell
>> From Kristján V. Jónsson <kristjan at ccpgames.com> on 24 Nov 2006:
>>> Here is a quick question for you, before I make a fool of 
>> my self on 
>>> the more mainstream Python lists..
>>> Why is the exception state kept around with a frame after it is 
>>> handled?=
>>>   Hence the need for sys.exc_clear()
>>> Is this an implementation issue or a language design feature?
>>> Cheers,
>>> Kristján
>> _______________________________________________________
>> The FREE service that prevents junk email http://www.mailshell.com

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list