Adding extra frames to traceback in C module

Roger Binns rogerb at rogerbinns.com
Fri Jun 9 23:24:05 EDT 2006


One thing I would like to do in my extension module is
add extra frames to the traceback when an extension
occurs.  At the moment C code is invisible to tracebacks.
This is relevant when the C code makes a Python callback.
For example if the following code sequence happens
(time going down)

Python     C

  A
  B
  C
           D
           E
           F
  G
  H

If there is an exception in H then the traceback seen
from A will be "B C G H".  I want to get D, E and F
into there as well.  This is because "G H" could be
called for several different reasons in the C code
and adding the extra information will establish why.

I couldn't find anything on the web or in the documentation
to explain how to do it.  I did find snippets of code
doing things like PyTraceback_Here but they use a real
Python frame which I don't have and don't know how to
synthesize.

Roger 





More information about the Python-list mailing list