Boost logo

Boost Users :

From: Marco Biasini (mbiasini_at_[hidden])
Date: 2008-06-27 05:21:45


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.


#include <boost/python.hpp>

using namespace boost::python;

class CppClass {
   int getNum() {
     return 7;

int main( int argc, char ** argv ) {
   try {

     object main_module((

     object main_namespace = main_module.attr("__dict__");
        main_namespace["CppClass"] = class_<CppClass>("CppClass")
        handle<> ignored(( PyRun_String( "cpp = CppClass();print cpp.getNum()
                                      main_namespace.ptr() ) ));
   } catch( error_already_set ) {

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



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at