[Stackless] A question about exceptions

Kristján V. Jónsson kristjan at ccpgames.com
Fri Nov 24 17:46:41 CET 2006

Well, Perhaps My question wasn't clear enough:

def foo():
	except ZeroDivisionError:
		#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.


> -----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

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list