[Python-3000] self-contained exceptions
Guido van Rossum
guido at python.org
Thu Jan 4 04:38:24 CET 2007
On 1/3/07, Ka-Ping Yee <python at zesty.ca> wrote:
> On Wed, 3 Jan 2007, Adam Olsen wrote:
> > That can be solved by moving the weakref to the stack frame -> exc
> > part, and only turning it from a strong reference into a weak
> > reference when the function exits. When debugging via the raised
> > exception, the chain of __context__ references would keep it alive.
>
> That seems like a reasonable approach to me. The implementation
> might be tricky, but the behaviour sounds correct.
Which reference are you exactly turning into a weak ref? The hidden
reference in the frame's f_exc_traceback? Or the variable 'err' in
except Exception, err: ...
? The former goes away anyway so I'm not sure that this helps. And the
latter seems fraught with peril; how do we even know which variables
to treat this way? And why isn't it just as good to simply *delete*
all locals that ever occurred in such a position in an except clause?
Or am I totally misunderstanding? Do note that there's a long comment
in ceval.c explaining how exceptions are stored in the thread state
and in the frame, right above set_exc_info().
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list