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

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Mar 6 01:19:05 CET 2009


Sorry I cannot help any further; I've never used embedding myself. I hope someone
else will step in.

For the archives:

http://www.boost.org/doc/libs/1_38_0/libs/python/todo.html#pyfinalize-safety

I believe you're just getting lucky if Py_Finalize() doesn't crash the process.





----- Original Message ----
From: Igor Karpov <ikarpov at gmail.com>
To: Ralf W. Grosse-Kunstleve <rwgk at yahoo.com>
Cc: Development of Python/C++ integration <cplusplus-sig at python.org>
Sent: Thursday, March 5, 2009 1:46:26 PM
Subject: Re: [C++-sig] boost::python embedding error - runtime - Mac OS X -  1.38

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;

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
>



More information about the Cplusplus-sig mailing list