Raising objects

Greg Ewing (using news.cis.dfn.de) ckea25d02 at sneakemail.com
Mon May 5 21:41:02 EDT 2003


Steven Taschuk wrote:
> The implementation of raise -- see Python/ceval.c:/^do_raise --
> calls PyErr_NormalizeException if appropriate, so an exception
> raised by Python code will get normalized immediately,
> 
> But when a C function signals an exception by PyErr_SetObject and
> returns NULL, its C caller could indeed deal with the exception
> without calling PyErr_NormalizeException,
> 
> At first glance I don't see that this is desirable.  Maybe it's
> used for performance in certain for loops or something.

Yes, any for-loop that iterates over a built-in type, in
fact. Otherwise an instance of StopIteration would have to
be created every time such a loop terminated.

But seeing as this trick can only be taken advantage of
by C code, there's no reason that "raise C, v" couldn't
be eliminated in favour of "raise C(v)".

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list