[Python-Dev] tstate->curexc_type etc
Greg Ewing
greg@cosc.canterbury.ac.nz
Thu, 23 May 2002 13:08:51 +1200 (NZST)
Christian Tismer <tismer@tismer.com>:
> in new Stackless, I saved
> tstate->exc_type/value/traceback and
> tstate->curexc_type/value/traceback
> Why is there this double set of variables,
I've just been wrestling with this stuff recently for Pyrex,
and as far as I can tell, this is how it works:
When an exception is set, it is put into
curexc_{type,value,traceback} and unwinding of
the stack begins, searching for a handler.
When a handler is found, the exception is transferred
to exc_{type,value,traceback} and execution of the
handler begins.
In other words, curexc_* holds an exception which
has been set but not yet caught, and exc_* holds
an exception which has been caught and is now
being handled.
> which one should be preserved if at all
> between tasklet switches?
I think you'll have to save exc_*, since a task switch
could occur during execution of an except-block.
You may get away without saving curexc_*, if it's
impossible for a task switch to occur while in the
middle of unwinding the stack looking for a
matching except-clause.
> Under PythonWin, I saw crashes due to dangling
> references through that, which vanished when
> I increfed the exc_/... things. Problably they
> were multiply reset.
I wouldn't fix that by putting in random increfs.
You'd better find out exactly what's going on and
make it do the right thing!
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+