[issue14930] Make memoryview weakrefable
Richard Oudkerk
report at bugs.python.org
Mon May 28 14:50:03 CEST 2012
Richard Oudkerk <shibturn at gmail.com> added the comment:
> In the test, you should call gc.collect() so that it works on non-
> reference counted implementations.
I did think about using gc.collect(), but I was not sure whether it was guaranteed to collect everything possible if you only call it only once. (I know nothing about garbage collectors.)
> Also, I would call PyObject_ClearWeakRefs() after memory_release() and
> Py_CLEAR(self->mbuf), not before (in case a weakref callback relies on
> the buffer being released).
Doing it after Py_CLEAR(self->mbuf) seems to contradict
http://docs.python.org/dev/extending/newtypes.html?highlight=pyobject_clearweakrefs#weak-reference-support
which says
The only further addition is that the destructor needs to call the weak
reference manager to clear any weak references. This should be done *before*
any other parts of the destruction have occurred, but is only required if the
weak reference list is non-NULL:
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14930>
_______________________________________
More information about the Python-bugs-list
mailing list