[C++-sig] BPL and Py_Clear()

David Abrahams dave at boost-consulting.com
Fri Jun 10 19:08:02 CEST 2005


"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 10 Jun 2005 at 14:57, Niall Douglas wrote:
>
>> How well does BPL handle Py_Clear() being called on a wrapped object
>> instance when there are still plenty of referants around? What happens
>> if something tries to access the wrapped object instance after it has
>> been cleared? Does it get None, or does it crash?
>
> Actually ignore this question. However, I have another:
>
> How do you absolutely ensure a BPL wrapped object ceases to exist? In 
> other words, if python code has ten references to a BPL wrapped 
> object and I want that object to die immediately, therefore I would 
> have to ensure either (a) the BPL wrapped object becomes a zombie or 
> (b) each and every reference to that object is set to None.
>
> The latter sounds more appealing. I'm assuming I'd have to walk some 
> table in Python?

There is no known mechanism for the latter.

The former is easy: make sure the object is held by auto_ptr<T>, and pass
the object to a function accepting an auto_ptr<T>.

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




More information about the Cplusplus-sig mailing list