How do I catch an exception thrown in ctypes?

I am working with some C code that is called from Python using ctypes. Somewhere in the bowels of the C library, an exception and / or interrupt () occurs. Is there a way that I can catch this in my python codebase? (Linux platform)

+2


a source to share


1 answer


You might be able to set up a signal handler on SIGABRT to handle the signal called by abort (). However, failed assertions can be combined with corrupted memory and other bad things - usually the reason the assertion failed. Thus, usually terminating applications is the best thing you can do (other than displaying / registering the error in your handler before terminating).



+3


a source







All Articles