[C++-sig] copy boost::python::object crashes

sergun gerasimov at mlab.cs.msu.su
Sat Jan 23 16:59:33 CET 2010


I have a problem with storing reference to Python object inside C++.

The following Boost.Python wrapping class:



#include <boost/python.hpp>

using namespace boost;
using namespace boost::python;

namespace cmodule
{

object y;

void setY(object y1) { y = y1; }

}

using namespace cmodule;

BOOST_PYTHON_MODULE(cmodule)
{
	def("setY",setY);
}




Crashes with “Segmentation fault” on so simple python fragment.




import cmodule

class Foo:
    pass

cmodule.setY(Foo())




When I comment “y = y1;” assignment everything is fine.

What I’m doing wrong?

Python version: 2.6
Boost version: 1.41
OS: FreeBSD 8.0

Sergey Gerasimov.




More information about the Cplusplus-sig mailing list