[C++-sig] Problems with Python "Factories"

Achim H. achim-bpl at mol-net.com
Thu Apr 6 11:37:08 CEST 2006


Am Donnerstag, 6. April 2006 11:04 schrieb Lloyd Weehuizen:
> I've managed to set up the wrappers for the types and everything works
> great up until I call the InstanceType method on a python based factory
> from C++. The object is created and returned correctly to C++ from
> python. The C++ wrapper then uses extract<> to pull out the
> FactoryBaseType and return it to the callee and thats where it all goes
> wrong. When the wrappers InstanceType completes the local
> boost::python::object that has its pointer extracted from goes out of
> scope and the extract'd pointer becomes a dangling pointer as nobody is
> referencing the constructed python object anymore.
>
> I'm not exactly sure how to solve this, do I have to hack around this by
> implementing some kind of temporary reference on the object? Or is there
> some way around this problem that I've missed?

I asked a similar question last week and there is no real solution.
See the thread with these messages:

http://article.gmane.org/gmane.comp.python.c++/9528
http://article.gmane.org/gmane.comp.python.c++/9546

Achim.

P.S.: Somehow, I can only find my own mails from this thread on gmane, not the 
answers from other people. Does anybody know the reason why?




More information about the Cplusplus-sig mailing list