Hi!
I've got a problem when using boost.python on MacOS X. The program
exits with
TypeError: attribute name must be string
This happens both in boost 1.34 and 1.35. I was however able to
run attached snippet without problems with boost 1.33.
Code:
#include
using namespace boost::python;
class CppClass {
public:
int getNum() {
return 7;
}
};
int main( int argc, char ** argv ) {
try {
Py_Initialize();
object main_module((
handle<>(borrowed(PyImport_AddModule("__main__")))));
object main_namespace = main_module.attr("__dict__");
main_namespace["CppClass"] = class_<CppClass>("CppClass")
.def("getNum",&CppClass::getNum);
handle<> ignored(( PyRun_String( "cpp = CppClass();print cpp.getNum()
\n",
Py_file_input,
main_namespace.ptr(),
main_namespace.ptr() ) ));
} catch( error_already_set ) {
PyErr_Print();
}
}
Specs, if it should matter:
* MacOS 10.4.11, 2.14 GhZ Core 2 Duo
* Compiler gcc 4.0.1 (Apple, Inc.), Python 2.4 (MacPorts)
Any suggestions/directions? Please let me know if you need additional
information.
Best,
Marco