[C++-sig] Re: The "return always existing pointer throws dangling error" problem

Niall Douglas s_sourceforge at nedprod.com
Wed Oct 22 20:05:54 CEST 2003


On 22 Oct 2003 at 8:10, David Abrahams wrote:

> In any case, I'm done discussing our communication disconnect, and I'm
> returning to technical issues for the remainder of this thread.

No problem, and thanks for indulging my off-topic interest in this 
matter. Someday I'll write a book on managing IT projects where I'll 
hopefully improve on "The Mythical Man Month".

> None of this is to say that there's something wrong with the
> "metadata" approach. My proposal isn't completely general - it doesn't
> apply in cases where virtual function default implementations aren't
> involved.  The metadata probably would be implemented with a virtual
> function on Holder classes which would return true iff the lifetime of
> the held C++ object was dependent on that of the Python object.

Interesting, and a source of ideas for my own solution.

> Sadly, I don't know when I'd have time to implement any of this; I'm
> desperately trying not to fall behind on a book I'm writing.

I'm thinking the best short-term stop-gap solution is an alternate 
call_method which basically disables the dangling pointer check. Then 
you can mark off functions in pyste which would fall foul of this 
particular problem on a case-by-case basis.

The:
       object self(handle<>(borrowed(m_self)));
       return extract<Foo*>(self.attr("f")());

... solution I previously mentioned is of course unsuitable because 
attr() cannot take parameters.

Cheers,
Niall




-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 208 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20031022/28835640/attachment.pgp>


More information about the Cplusplus-sig mailing list