returning Python exceptions. EXPP_ReturnPyObjError() always returns a NULL because Python expects error conditions to return a NULL pointer instead of an object. Since the pointer is cast to a PyObject *, it's ugly to use for propagating the errors back in this case, so this fix just uses PyErr_SetString() to set the error and return NULL (see the body of EXPP_ReturnPyObjError() ).