BTW, this seems specific to 1.38.0 version of Boost - I just downgraded to 1.34.1 on the same mac, and got the expected "Hello World from boost::python!".
--Igor. On Thu, Mar 5, 2009 at 12:47 PM, Igor Karpov <[email protected]> wrote: > Hi, > > I am trying to run the following program: > > #include <iostream> > #include <Python.h> > > #include <boost/python.hpp> > using namespace boost::python; > > using namespace std; > > int main(int argc, char** argv) { > > { // Using Python/C > Py_Initialize(); > PyObject* main_module = PyImport_ImportModule("__main__"); > PyObject* globals = PyEval_GetGlobals(); > PyObject* locals = PyEval_GetLocals(); > PyRun_SimpleString("print 'Hello World, from Python/C!'\n"); > Py_Finalize(); > } > > { // Using boost::python > Py_Initialize(); > object main_module = import("__main__"); > object main_namespace = main_module.attr("__dict__"); > try { > object ignored = exec("print 'Hello World, from boost::python!'\n", > main_namespace); > Py_Finalize(); > } catch (error_already_set const& e) { > PyErr_Print(); > return 1; > } > } > > return 0; > } > > on Linux (both x86 and x86_64), with Ubuntu's default version of Boost > (1.34.1) installed, I am able to do so as expected: > > $ ./embed > Hello World, from Python/C! > Hello World, from boost::python! > > on Mac OS X, I get a runtime error: > $ ./embed > Hello World, from Python/C! > Bus Error > > Running with gdb, this is the stack trace: > > Hello World, from Python/C! > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 > 0x00000000 in ?? () > (gdb) where > #0 0x00000000 in ?? () > #1 0x00bb618f in PyEval_GetGlobals () > #2 0x00bce0dd in PyImport_Import () > #3 0x00bce2b0 in PyImport_ImportModule () > #4 0x008127d4 in boost::python::import (na...@0xbffff4a8) at > libs/python/src/import.cpp:20 > #5 0x00004446 in main (argc=1, argv=0xbffff510) at embed.cc:22 > > For this Mac, boost version is latest (1.38) and python version is: > > Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) > [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin > > Is this a bug? I attached the source and the cmake file I am using to > build, for convenience. > > Thanks, > > --Igor. > _______________________________________________ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
