[Pyrex] Pyrex exception reraise behavior

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jul 24 08:54:49 CEST 2008


Miles wrote:

> It looks to me like Pyrex's behavior for reraising exceptions differs
> somewhat from Python's:

There are some differences, yes. Python makes the
sys.exc_info() vars dynamically scoped by saving and
restoring them in the Python stack frame every time
a call occurs.

That would be too expensive for Pyrex, so it uses
a different approach -- it stores information about
the caught exception in the C stack frame at the
point where it's caught (i.e. in the except clause).
The raise statement is required to be lexically
enclosed in the except clause so that it can access
this information.

There may be some other differences as well. What
you appear to be seeing is a leaking of the
sys.exc_info() outside the scope where it would
normally be available in Python.

Is this causing a real difficulty, or is it just
a curiosity? I'm not sure how easy it would be
to fix.

-- 
Greg



More information about the Pyrex mailing list