Hello all,
I recently installed Boost using MacPorts, with the intent to do some Python embedding in C++. I then decided to check if I configured Xcode correctly with an example found on Python's website:
#include <boost/python.hpp>
using namespace boost::python;
int main( int argc, char ** argv )
{
try
{
Py_Initialize();
object main_module(handle<>(borrowed(PyImport_AddModule("__main__"))));
object main_namespace = main_module.attr("__dict__");
handle<> ignored(PyRun_String("print \"Hello, World\"",
Py_file_input,
main_namespace.ptr(),
main_namespace.ptr()));
}
catch( error_already_set )
{
PyErr_Print();
}
}
It compiles correctly, but when I launch it, the call to attr() throws an exception, and the resulting error message is "TypeError: attribute name must be string, not 'str'". Which suspiciously sounds like a placeholder.
I looked it up on Google, but no luck.
I use Boost v1.39, Python 2.5 and GCC 4.0, on Leopard.