I want to catch a custom C++ exception in Python. I have described my
custom exception class as usual:
class_<CMyException>(...);
and created a translator:
void translate(CMyException const &e) {
object o(e);
PyErr_SetObject(PyExc_Exception, o.ptr());
}
This exception can be caught from Python:
try:
do_something()
except Exception as exc:
#exc.args[0] - the custom exception object
print exc.args[0]
Is it safe to do in such a way? Is the Python object, created in the
function "translate", destroyed? Need I add "Py_INCREF" to this function?
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig