<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
This is all about current (3.6) trunk.<br>
<br>
In Objects/weakrefobject.c, we have the function
PyObject_ClearWeakRefs(). This is called when a generic object that
supports weakrefs is destroyed; this is the code that calls the
callbacks. Here's a little paragraph of code from the center:<br>
<br>
<blockquote><tt>for (i = 0; i < count; ++i) {<br>
PyWeakReference *next = current->wr_next;<br>
<br>
if (((PyObject *)current)->ob_refcnt > 0)<br>
{<br>
Py_INCREF(current);<br>
PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);<br>
PyTuple_SET_ITEM(tuple, i * 2 + 1,
current->wr_callback);<br>
}<br>
else {<br>
Py_DECREF(current->wr_callback);<br>
}<br>
current->wr_callback = NULL;<br>
clear_weakref(current);<br>
current = next;<br>
}</tt><br>
</blockquote>
"current" is the doubly-linked list of PyWeakReference objects
stored inside the object that's getting destroyed.<br>
<br>
My question: under what circumstances would ob_refcnt ever be 0?
The tp_dealloc handler for PyWeakReference * objects removes it from
this list and frees the memory. How could the reference count reach
0 without tp_dealloc being called and it being removed from the
list?<br>
<br>
Scratching my head like crazy,<br>
<br>
<br>
<i>/arry</i><br>
<br>
p.s. If you're thinking "why does he care?", understanding this
would maybe help with the Gilectomy. So yes there's a point to this
question.<br>
</body>
</html>