Returning exceptions to C

Developer jonp at bhmi.com
Tue Mar 21 15:35:27 EST 2000


I am trying to properly embed Python into a C++ program but with little
success.  The problem I am running into is when I try to capture the raised
exception in the C++ code.  The PyErr_Fetch() is not doing what I think it
is.  The exception is raised in the Python code and the retrun value is
Py_None.  Shouldn't the PyErr_Fetch() caputer the raise exception?  Here is
a snip ...

        pStr = PyEval_CallObject(pFunc, pArgs);
        if (pStr != Py_None)
        {
                ...
         }

        else
        {
            PyObject *errobj, *errdata, *errtraceback, *pystring;

            PyErr_Fetch(&errobj, &errdata, &errtraceback);

            ...

        }






More information about the Python-list mailing list