A
Andrew Ayre
Hi, I have a script that I want to execute from C. I don't want to call any
functions, just execute the script. Below is a code snippet.
The problem is that PyObject_CallObject always returns NULL. Is this the
correct return value for simply executing a script, as there is no function
return value involved?
// load script
pname = PyString_FromString(SCRIPTFILENAME);
pmodule = PyImport_Import(pname);
Py_DECREF(pname);
if (pmodule != NULL)
{
// execute script
presult = PyObject_CallObject(pmodule, NULL);
if (presult == NULL)
{
Py_DECREF(pmodule);
return;
}
Py_DECREF(presult);
Py_DECREF(pmodule);
}
else
{
return;
}
regards, Andy
(e-mail address removed) (remove year to reply)
functions, just execute the script. Below is a code snippet.
The problem is that PyObject_CallObject always returns NULL. Is this the
correct return value for simply executing a script, as there is no function
return value involved?
// load script
pname = PyString_FromString(SCRIPTFILENAME);
pmodule = PyImport_Import(pname);
Py_DECREF(pname);
if (pmodule != NULL)
{
// execute script
presult = PyObject_CallObject(pmodule, NULL);
if (presult == NULL)
{
Py_DECREF(pmodule);
return;
}
Py_DECREF(presult);
Py_DECREF(pmodule);
}
else
{
return;
}
regards, Andy
(e-mail address removed) (remove year to reply)