I am trying to run, in a C++ program, some python file that is actually included in the C++ code as a std::string called command.
I have been successful using PyRun_SimpleString(command.c_str()), but this prevents getting exception information.
I now try the following instead:
PyObject* result = PyRun_String(command.c_str(), Py_file_input, PyEval_GetGlobals(), PyEval_GetLocals());
However, this throws:
SystemError: frame does not exist
What am I doing wrong?
UPDATE:
I tried to split the process into compile+eval using the following:
PyObject* code = Py_CompileString(command.c_str(), filename.c_str(), Py_file_input);
PyObject* result = PyEval_EvalCode(code, PyEval_GetGlobals(), PyEval_GetLocals());
Now, the error is different:
SystemError: PyEval_EvalCodeEx: NULL globals
This is maybe more explanatory, as it says in the C API doc::
Return a dictionary of the global variables in the current execution frame, or NULL if no frame is currently executing.
I am not sure I understand what a frame is.