0

我向 python 公开了两个类:

BOOST_PYTHON_MODULE(client)
{
class_<Error>("Error")
   .def("GetErrorCode", &Error::GetErrorCode)
   .def("GetDescription", &Error::GetDescription)
   .def("__nonzero__", &Error::operator bool);

class_<Client>("Client")
   .def("Execute", &Client::Execute);
}

这是 Execute 方法的声明:

void Client::Execute(boost::python::object callable)
{
    Error e;
    callable(e);
}

这是我的python代码:

import client

def on_execute(error):
    print error.GetDescription()

c = client.Client()
c.Execute(on_execute)

这会因分段错误而失败。调试器说我无法将错误对象转换为 python。如何解决这个问题?

4

0 回答 0