How to exit Python nicely after error in embedded C code?
Edward C. Jones
edcjones at erols.com
Tue Feb 27 00:30:37 EST 2001
Suppose I have a C function that is called only by other C functions (so it
doesn't return a PyObject *). If I find an error condition in the the C
function, is there function I can call that will exit the C code back into
Python so Python can clean up and exit. The function is called by many different
C function in case of error.
int error_callback(int status, char * funcname) {
if (status != 0) {
printf("Error occured in %s\n", funcname);
/* Is this part of what I want: */
PyErr_SetString(PyExc_Exception, "Error in C function");
/* ... what goes here ... */
}
return 0;
}
I am using Python and C on a Linux system.
Thanks,
Ed Jones
More information about the Python-list
mailing list