[C++-sig] Duplicate registration of to-Python converters

Roman Yakovenko roman.yakovenko at gmail.com
Thu Mar 22 14:28:46 CET 2007


On 3/22/07, Pertti Kellomäki <pk at cs.tut.fi> wrote:
> We are developing a system that allows user-written
> plugins. Some of these plugins can be written in
> Python, and they can access the internals of the
> system via bindings developed using Boost.Python.
>
> The plugins don't know anything about each other, so
> a plugin running Python calls Py_Initialize(), runs
> the Python code, and calls Py_Finalize().
>
> The call to Py_Finalize() does not remove the registered
> to-Python converters, however, so if two plugins happen
> to import the same module produced by Boost.Python, the
> second importing causes RuntimeWarnings to be printed.
>
> Is there a way to turn these warnings off, remove the
> converters, or otherwise circumvent the problem?

even few

1. Find out the warning and remove it :-)
2. register only new classes:

namespace bpl = boost::python;
bpl::handle<> class_obj(
bpl::objects::registered_class_object(bpl::type_id<my_class_t>()));

if( class_obj.get() == 0 ){
    bpl::class_<my_class_t>( ... );
}


HTH
-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list