I am using a library, which specifies in its API docs to define a class inherited from some particular class of of the library. The library itself is written in C++ and the bindings to Python is generated using SWIG. The problem is, when I run my Python code, no matter what exception Python throws, I get the error saying "terminate called after throwing an instance of 'Swig::DirectorMethodException'".

I would like to have this exception raised by the Python code to be reported while executing my program. Esp, those cases where I get ZeroDivisionError.

I tried to hack a bit by following the method described in the SWIG documentation at <http://www.swig.org/Doc2.0/Python.html#Python_nn36> but with no luck. I still get the same message "terminate called after throwing an instance of 'Swig::DirectorMethodException'" no matter what I put in the module.i file.

Can some one please give me pointers on how to go about with this problem, so that Python exceptions are reported as they are?