Raising exceptions during call back

Makhno mak at imakhno.freeserve.co.uk
Mon May 29 08:15:59 EDT 2000


My C extension module calls back to Python subroutines that the user has
written. The trouble is, if the user makes an error, the sub isn't called (I
just get NULL). Printing a stack track (with print_stack) just shows the
Python stack up to the moment that it entered call back, and shows nothing
about the error in the subroutine.

What can I do to get the stack information during the subroutine itself?
eg

def mysub():
    t=(1,2)
    print t[3] #error!

EnterCallBack()

If I call print_stack() from the extension module, I only get trace
information up to the EnterCallBack() call, it says nothing about where an
error occured inside mysub(), which I'm sure you can imagine would make it
very difficult to write code for.







More information about the Python-list mailing list