[Pyrex] Reraise not inside except clause

Phillip J. Eby pje at telecommunity.com
Wed Oct 17 16:16:54 CEST 2007


At 06:47 PM 10/16/2007, Greg Ewing wrote:
>Robert Kern wrote:
>
> > The code looks correct to me. Can you see anything wrong with it?
>
>Okay, I've looked at it, and I can see what he's doing.
>But a try-except block would achieve pretty much the
>same thing. The code generated by 0.9.2 for a try-except
>that doesn't catch the exception value would be almost
>identical to what he's written out the hard way here.

Yeah, this code was written for a MUCH older version of Pyrex.


>So my fix for this would be to rip all that stuff out
>and replace it with getattr() (which compiles to a
>PyObject_GetAttr call in 0.9.2) and a try-except block
>containing a reraise.
>
>The next release will also have a getattr3() function
>(3-argument form) which could be used as an alternative.

Three argument form won't help here, as the AttributeError case falls 
through to more complex calculation.

Offhand, it seems like the right thing to do here, since the raise 
doesn't need to have high performance, they could just raise 
*sys.exc_info().  (So to speak.)





More information about the Pyrex mailing list