I am having trouble with the following code:
PyObject *module = PyImport_Import Module(modulena me);
if (module == NULL) {
PyObject* et, *ev, *etr;
PyErr_Fetch(&et , &ev, &etr);
PyObject* traceback = PyImport_Import Module("traceba ck");
PyObject* tb = PyObject_CallMe thodObjArgs(tra ceback,
PyString_FromSt ring("format_ex ception"), et, ev, etr, NULL);
char *message = PyString_AsStri ng(PyObject_Str (tb));
...
...
}
When this code executes, it gets into the "module == NULL" condition.
However, when I try to get the exception that occurred, I get the
value "<NULL>" copied into the "char* message" variable.
Can anyone shed some light on what might cause this to happen? I
thought that if I actually get into that NULL condition that an
exception has occurred.
PyObject *module = PyImport_Import Module(modulena me);
if (module == NULL) {
PyObject* et, *ev, *etr;
PyErr_Fetch(&et , &ev, &etr);
PyObject* traceback = PyImport_Import Module("traceba ck");
PyObject* tb = PyObject_CallMe thodObjArgs(tra ceback,
PyString_FromSt ring("format_ex ception"), et, ev, etr, NULL);
char *message = PyString_AsStri ng(PyObject_Str (tb));
...
...
}
When this code executes, it gets into the "module == NULL" condition.
However, when I try to get the exception that occurred, I get the
value "<NULL>" copied into the "char* message" variable.
Can anyone shed some light on what might cause this to happen? I
thought that if I actually get into that NULL condition that an
exception has occurred.
Comment