Re: Is there any way to catch expections when call python method in C++

2007-06-14 Thread Gabriel Genellina
En Wed, 13 Jun 2007 12:03:00 -0300, Robert Bauck Hamar <[EMAIL PROTECTED]> escribió: > Allen wrote: > >> I use try catch, but cannot catch the execeptions of execution python >> method. > > No. CPython is written in C, not C++, and C has no concept of exceptions. > Exceptions in Python is usuall

Re: Is there any way to catch expections when call python method in C++

2007-06-13 Thread Robert Bauck Hamar
Allen wrote: > 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 =

Re: Is there any way to catch expections when call python method in C++

2007-06-13 Thread cptnwillard
One way is to create an intermediate python function, which returns a special value when an exception is caught. def ExceptionCatcher(FunctionToCall): def F(): try: FunctionToCall() except: return -1 return 0 return F Then instead of calling your function, you woul

Is there any way to catch expections when call python method in C++

2007-06-13 Thread 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(); PyObjec