[C++-sig] boost::python embedding error - runtime - Mac OS X - 1.38

Thomas Berg merlin66b at gmail.com
Fri Mar 6 18:38:10 CET 2009


Hi,

On Thu, Mar 5, 2009 at 10:46 PM, Igor Karpov <ikarpov at gmail.com> wrote:
> Well, the version with Py_Finalize() runs on the same machine with
> 1.34.1, so I don't think that's the problem. However, paring down the
> code to:
>
> #include <Python.h>
> #include <boost/python.hpp>
> using namespace boost::python;


Not sure it will make a difference in your case, but the boost.python
documentation does specify that you should never include Python.h
yourself. boost.python does it for you, taking care of several #define
issues:
http://www.boost.org/doc/libs/1_38_0/libs/python/doc/building.html#include-issues

- Thomas



> int main(int argc, char** argv) {
>
>    { // 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);
>        } catch (error_already_set const& e) {
>            PyErr_Print();
>            return 1;
>        }
>    }
>
>    return 0;
> }
>
> Will re-create the same Bus error at runtime...
>
> --Igor.
>
> On Thu, Mar 5, 2009 at 3:26 PM, Ralf W. Grosse-Kunstleve <rwgk at yahoo.com> wrote:
>>
>>>        Py_Finalize();
>>
>>
>> Boost.Python doesn't support Py_Finalize(). Could you try again without?
>> It is a long-standing known issue, e.g.
>> http://mail.python.org/pipermail/cplusplus-sig/2005-November/009543.html
>>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>


More information about the Cplusplus-sig mailing list