I'm encountering an issue (more precisely a segmentation fault) while trying to pass a "Python" string to a std::string as function argument while trying to build a binder.
Some more details.
The C++ signature of the function to be called is :
Code: Select all
bool FooClass::FooFunc(std::string);
Code: Select all
PyObject* FooClass::sFooFunc(PyObject * /*self*/, PyObject *args)
{
PyObject* obj;
if (!PyArg_ParseTuple(args, "s", &obj))
return NULL;
bool ok = FooFunc(Py::Object(obj).as_string());
return Py::new_reference_to(Py::Boolean(ok));
}
Code: Select all
bool ok = FooFunc(Py::Object(obj).as_string());
I also tried
Code: Select all
bool ok = FooFunc(Py::String(obj).as_string());
May one know what is the proper way to convert the binder string argument into an std::string and pass it to the function ?
TIA