![]() |
#21
|
|||
|
|||
Ok, I have a (temporary) solution:
In my C++ code I have defined a helper function modeled after the ones in your viz/python include: Code:
// helper for making the list to communicate an exception // Returns new reference to list of a python object and a string inline PyObject* PYTHON_EXCEPTION_STRING_LIST(PyObject* exc, const char * msg) { PyObject *list = PyList_New(2); PyList_SET_ITEM(list,0,exc); PyList_SET_ITEM(list,1,PyString_FromString(msg)); return list; } Code:
data.set( PYTHON_RETURN_OBJECT, PYTHON_EXCEPTION_STRING_LIST(PyExc_RuntimeError,"testing"); Code:
# function that should be wrapped around any interaction with the stimulus class through command()s # detect if an error case is communicated, if not, simply pass on the input def errorHandler(self,input): if isinstance(input,list) and issubclass(input[0],BaseException): # we have an exception to handle, raise it raise input[0](input[1]) # raise exception communicated by C++ code else: return input I suppose this is dirty and not how its supposed to be done, but tis a workaround for now. Hope you can show me how to get PyErr_SetString to work! |
|
|