A
Allen
I use try catch, but cannot catch the execeptions of execution python
method.
PYCALL_API void PyCall(const char * pszModule, const char * pszFunc,
void * pArg)
{
if (pszModule == NULL || pszFunc == NULL)
{
return;
}
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
try {
pModule = PyImport_ImportModule(pszModule);
pFunc = PyObject_GetAttrString(pModule, pszFunc);
PyEval_CallObject(pFunc, (PyObject*)pArg);
} catch (...) {
fprintf(stderr, "Error: call python method failed");
}
Py_Finalize();
}
Can I catch it from C++? Thank you.
Regards,
Allen Chen
method.
PYCALL_API void PyCall(const char * pszModule, const char * pszFunc,
void * pArg)
{
if (pszModule == NULL || pszFunc == NULL)
{
return;
}
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
try {
pModule = PyImport_ImportModule(pszModule);
pFunc = PyObject_GetAttrString(pModule, pszFunc);
PyEval_CallObject(pFunc, (PyObject*)pArg);
} catch (...) {
fprintf(stderr, "Error: call python method failed");
}
Py_Finalize();
}
Can I catch it from C++? Thank you.
Regards,
Allen Chen