[C++-sig] BPL and Py_Clear()
Niall Douglas
s_sourceforge at nedprod.com
Sat Jun 11 16:03:26 CEST 2005
On 10 Jun 2005 at 13:08, David Abrahams wrote:
> > 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>.
The latter could probably be made to work if given enough time, but
it would require a substantial amount of alterations to pyste to
achieve it - and even then, I still can see issues which may arise.
Hence I must go the quick & dirty route. I was thinking of throwing a
dummy exception, reading the traceback & stack frame info and
recursing up through the globals() in each deleting any references to
my object. This would surely do it for the current interpreter at
least?
Cheers,
Niall
More information about the Cplusplus-sig
mailing list