[C++-sig] Exception 'No to_python (by-value) converter found - 'garbage collection'

David Abrahams dave at boost-consulting.com
Mon Sep 18 22:45:00 CEST 2006


"Eduardo Picado" <eduardo.picado at gmail.com> writes:

> Hi,
>
> Im writing the following kind of python code using a C++ wrapped library:
>
>
>
> system = TASRSystem.getASRSystem()
> system.setParameter(TASRSystem.Option.asrServersListenPort, 32000)
>
> try:
> 	system.initialize(1, 3000)
> except Exception, e:
> 	sys.stderr.write("[E] : " +  e.__class__.__name__ + str(e) )
> print "ok"
>
>
>
> Running it I get:
>
>
>
> ok
> Exception exceptions.TypeError: 'No to_python (by-value) converter
> found for C++ type:
> class TASRSystem' in 'garbage collection' ignored
> Fatal Python error: unexpected exception during garbage collection

This surely means you've wrapped a C++ function that returns a
TASRSystem and that function is getting invoked from some Python
class' __del__ method.

> The declaration of TASRSystem is like:
>
> BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(TASRSystem_initialize_overloads_0_2,
> initialize, 0, 2)
>
> class_< TASRSystem, boost::noncopyable >("TASRSystem", no_init)
> 	.def("getASRSystem", &TASRSystem::getASRSystem,
> return_value_policy<reference_existing_object>())
> 	.def("initialize", &TASRSystem::initialize,
> TASRSystem_initialize_overloads_0_2())
> 	.staticmethod("getASRSystem")
>
>
> - TASRSystem.getASRSystem() is an static method, that creates and
> returns an instance of an ASRSystem. Seems ok.
> I've tried to use with_custodian_and_ward_postcall <1, 0>, to ensure
> that the lifetime of the created instance is as long
> as that of the Python object, but it didn't worked - gives "argument
> index out of range".

That's because the fewest number of arguments wrapped by your
invocation of BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS is zero.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list