[Patches] indexerror: better error messages

M.-A. Lemburg mal@lemburg.com
Mon, 12 Jun 2000 14:54:38 +0200


Peter Schneider-Kamp wrote:
> 
> "M.-A. Lemburg" wrote:
> >
> > Finding out the cause of an error is easy enough by
> > simply looking at the traceback when the error is being
> > printed.
> 
> I suppose this can be done inside the IndexError__str__
> method in Python/exceptions.c.

Right.
 
> But how do I access the traceback object to get the
> required information? I have looked closely at
> traceobject.c but didn't see anything that would help me.
> A short hint would be appreciated.

First, get the current thread state via PyThreadState_Get()
and then use ->curexc_traceback to find the information
needed. Note that for errors raised from C functions you won't
be able to use the traceback.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/