[C++-sig] BPL and Py_Clear()
Stefan Seefeld
seefeld at sympatico.ca
Fri Jun 10 16:46:00 CEST 2005
Niall Douglas 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. 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.)
Regards,
Stefan
More information about the Cplusplus-sig
mailing list