[C++-sig] [Boost.Python] Importing twice causes error in MSVS with Boost.Python extension?

David Abrahams dave at boost-consulting.com
Mon Aug 20 16:33:06 CEST 2007

on Wed Aug 15 2007, Lawrence Spector <Lawrence.Spector-AT-CanfieldSci.com> wrote:

> In one case I use “PyImport_ImportModule”.  Later on, I do “PyRun_String”.  Either way, same
> deal.  I import the module and the first time it succeeds.  The second time it blows up deep
> down in boost.  Ultimately an an assert fails, which can be traced down to
> boost::python::convert::registry::insert failing on an assertion of
> slot == 0 (line 160). 

That means the same type converters are being registered twice.
Python shouldn't let you actually load the same module twice (i.e. run
its init function) unless you do Py_Finalize(), which isn't supported
by Boost.Python.  If you're not actually loading the same module twice
then you've got some code registering type converters in a function
that is called multiple times.

Dave Abrahams
Boost Consulting

The Astoria Seminar ==> http://www.astoriaseminar.com

More information about the Cplusplus-sig mailing list