[C++-sig] BPL and Py_Clear()
Niall Douglas
s_sourceforge at nedprod.com
Fri Jun 10 17:41:48 CEST 2005
On 10 Jun 2005 at 10:46, Stefan Seefeld 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?
>
> That sounds quite unpythonic ! If I hold a reference to a python
> object, I don't expect that to die in the middle of a program.
Well true, but the library I am wrapping has parents eating their
young and if you don't tell python that the children are now invalid,
python segfaults.
> Actually, I have been debugging some code recently where I do some
> cleanup in a __del__ function of a global object, but the way python
> cleans up modules made those calls fail, since system modules I tried
> to use were already set to None. Fortunately that only happened at the
> end of a program, so the issue was relatively easy to work around.
> (Yet I'm not sure whether that can be considered a python bug.)
Yeah there's a lack of order of destruction much like C++ static
inits. It's unfortunate.
Cheers,
Niall
More information about the Cplusplus-sig
mailing list