[PyQt] SIP: passing exceptions Python -> C++

Jim Crowell jaclists at mailbolt.com
Mon Apr 28 17:58:45 BST 2008


I've got a C++ class with a whole bunch of virtual methods that are
overridden in Python subclasses.

These methods are callbacks, i.e. they're called repeatedly from a C++
event loop.

I want to catch any Python exceptions raised in any of these callbacks,
print the error messages, and then raise a C++ exception that will cause
the event loop to exit.

Is there an elegant way to do this without essentially re-implementing
all of the nice stuff that handles calling virtual methods? It looks
like all of the existing exception-mapping stuff is for going the other
direction, i.e. from C++ -> Python.

Thanks,
-Jim C.


More information about the PyQt mailing list