I am using boost::python to call some python code from C++.
std::string input = "{\"x\":1}";
auto objectpath = boost::python::import("objectpath");
auto Tree = objectpath.attr("Tree")(input);
auto tree = Tree.attr("execute")("$..x");
In python the corresponding execution is (objectpath):
$ python
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
1
But in C++ I am getting an error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/objectpath/core/interpreter.py", line 608, in execute
ret=exe(tree)
File "/usr/local/lib/python2.7/dist-packages/objectpath/core/interpreter.py", line 258, in exe
fst=exe(fst)
File "/usr/local/lib/python2.7/dist-packages/objectpath/core/interpreter.py", line 246, in exe
return self.data
AttributeError: 'Tree' object has no attribute 'data'
Python error, but failed to get the reason via PyErr
How can I fix my C++ problem?
Aucun commentaire:
Enregistrer un commentaire