[C++-sig] Strange boost python error message (and solution)
duranlef at iro.umontreal.ca
Fri May 19 20:43:10 CEST 2006
On Thu, 18 May 2006, Allen Bierbaum wrote:
> I just ran into a very strange error message in boost python that took
> me all afternoon to track down. I thought I would post the error and
> the solution here to:
> a) help other people out if they run into the same problem
> b) see if anyone can tell me what is really going on behind the
> scenes and if there is a way for boost python to detect it
> I was getting an assertion in boost::python::converter::registery::insert
> python: boost/libs/python/build/../src/converter/registry.cpp:162:
> void boost::python::converter::registry::insert(PyObject* (*)(const
> void*), boost::python::type_info): Assertion `slot == 0' failed.
> I tracked it down to having two calls to
> boost::python::register_ptr_to_python< boost::shared_ptr< MyClass > >
> . As long as there is only one call like this in the module for a
> single class things are fine. The second call causes a problem.
> So can anyone that knows the details of boost.python internals explain
> what is happening here?
> My guess (and it is only a guess) is that the registration of a
> to_python conversion function is detecting that it has already been
> set and asserting.
As far as I can tell from my understanding of the source code, this is
> If this is true, could the assertion be changed to
> something a little more descriptive like:
> assert((slot == 0) && "Attempted to register a to_python conversion
> function when one is already registered");
Sounds good. But also, would it be possible to detect if the same
to_python converter is get registered, and in such a case simply do
nothing and thus report no error?
LIGUM, Université de Montréal
"Il n'existe ni caprices du sort, ni bizarreries, ni accidents. Il n'y a
que des choses que les humains ne comprennent pas. [...] Les humains ne
peuvent exister si tout ce qui est déplaisant est écarté au lieu d'être
- Cygne Royal, dans _Message des hommes vrais au monde mutant_
(de Marlo Morgan)
More information about the Cplusplus-sig