Corrected an error in the information on supporting weak references in
extension types (the docs reflected a development version of the API). This closes SF bug #435066.
This commit is contained in:
parent
9ca78ac57f
commit
f66cb5d0eb
|
@ -226,28 +226,26 @@ PyTypeObject PyInstance_Type = {
|
||||||
0,
|
0,
|
||||||
"instance",
|
"instance",
|
||||||
|
|
||||||
/* lots of stuff omitted for brevity */
|
/* Lots of stuff omitted for brevity... */
|
||||||
|
|
||||||
offsetof(PyInstanceObject, in_weakreflist) /* tp_weaklistoffset */
|
offsetof(PyInstanceObject, in_weakreflist) /* tp_weaklistoffset */
|
||||||
};
|
};
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
The only further addition is that the destructor needs to call the
|
The only further addition is that the destructor needs to call the
|
||||||
weak reference manager to clear any weak references and return if the
|
weak reference manager to clear any weak references. This should be
|
||||||
object has been resurrected. This needs to occur before any other
|
done before any other parts of the destruction have occurred:
|
||||||
parts of the destruction have occurred:
|
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
static void
|
static void
|
||||||
instance_dealloc(PyInstanceObject *inst)
|
instance_dealloc(PyInstanceObject *inst)
|
||||||
{
|
{
|
||||||
/* allocate tempories if needed, but do not begin
|
/* Allocate tempories if needed, but do not begin
|
||||||
destruction here
|
destruction just yet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!PyObject_ClearWeakRefs((PyObject *) inst))
|
PyObject_ClearWeakRefs((PyObject *) inst);
|
||||||
return;
|
|
||||||
|
|
||||||
/* proceed with object destuction normally */
|
/* Proceed with object destuction normally. */
|
||||||
}
|
}
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
Loading…
Reference in New Issue