Exceptions from callbacks

Randall Hopper aa8vb at yahoo.com
Thu Nov 4 12:27:22 CET 1999


Eric Dorland:
 |Randall Hopper wrote:
 |
 |>   (Python) -> HandlePendingMessages -> MYLIB -> Callback -> (Python)
 |
 |I understand what you mean exactly. The problem is I can't do it that
 |way. Basically, the way the library works is that you register a bunch
 |of callbacks and then call a function (eg. Loop()) that doesn't return.
 |The HandlePendingEvents (its equivalent I mean :)) isn't exposed by the
 |library, so I can't wrap it :). That's way I want a way to force the
 |interpreter to realize an exception is there. Is there a way, or a work
 |around, to do this?

I see.  So in the wrapper layer for each Python callback, you want to check
whether an exception occurred, and if so, tell Python to print it
(pretending that it has popped all the Python stack frames at that point.

So you need the C equivalent of:

      traceback.print_exc()

I don't know what this is, but hopefully someone else will chime in.

Randall






More information about the Python-list mailing list