I need to read local variables from Python in C/C++. When I try to PyEval_GetLocals
, I get a NULL. This happens although Python is initialized. The following is a minimal example.
#include <iostream>
#include <Python.h>
Py_Initialize();
PyRun_SimpleString("a=5");
PyObject *locals = PyEval_GetLocals();
std::cout<<locals<<std::endl; //prints NULL (prints 0)
Py_Finalize();
In the manual, it says that it returns NULL if no frame is running, but... there's a frame running!
What am I doing wrong?
I'm running this in Debian Jessie.