R
rahul
I am implementing a C extension module, during this I saw that when I set the global error indicator and error message through PyErr_SetString() API and return false.
But it doesn't throw any error when I tried to check the error through sys.exc_info() then it returns (NULL, NULL, NULL) tuple.
When I return NULL through the C extension module's function then it works correctly and throws the exception as expected.
The skeleton looks like:
static PyObject* check(PyObject* sef, PyObject* args)
{
PyObject* input = NULL;
if (!PyArg_ParseTuple(args, "O", &input)){
return NULL;
}
.....
.....
PyErr_SetString(PyExc_Exception, "Throwing Error through check function");
Py_RETURN_FALSE;
}
Any idea on why this is happening? Any help will be appreciated.
Thanks,
Rahul
But it doesn't throw any error when I tried to check the error through sys.exc_info() then it returns (NULL, NULL, NULL) tuple.
When I return NULL through the C extension module's function then it works correctly and throws the exception as expected.
The skeleton looks like:
static PyObject* check(PyObject* sef, PyObject* args)
{
PyObject* input = NULL;
if (!PyArg_ParseTuple(args, "O", &input)){
return NULL;
}
.....
.....
PyErr_SetString(PyExc_Exception, "Throwing Error through check function");
Py_RETURN_FALSE;
}
Any idea on why this is happening? Any help will be appreciated.
Thanks,
Rahul