[Python-checkins] python/dist/src/Doc/lib libweakref.tex,1.17,1.18
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Wed, 07 Aug 2002 09:18:56 -0700
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv19689
Modified Files:
libweakref.tex
Log Message:
Described responsibilty of weakly referenced extension types to initialize
the weakreflist to NULL in the constructor and to fill the tp_flags
slot with Py_TPFLAGS_HAVE_WEAKREFS. Closes SF bug 586583.
Index: libweakref.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libweakref.tex,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** libweakref.tex 8 Dec 2001 18:02:49 -0000 1.17
--- libweakref.tex 7 Aug 2002 16:18:54 -0000 1.18
***************
*** 218,222 ****
object's constructor. It must also set the \member{tp_weaklistoffset}
field of the corresponding type object to the offset of the field.
! For example, the instance type is defined with the following structure:
\begin{verbatim}
--- 218,224 ----
object's constructor. It must also set the \member{tp_weaklistoffset}
field of the corresponding type object to the offset of the field.
! Also, it needs to add \constant{Py_TPFLAGS_HAVE_WEAKREFS} to the
! tp_flags slot. For example, the instance type is defined with the
! following structure:
\begin{verbatim}
***************
*** 239,244 ****
/* Lots of stuff omitted for brevity... */
! offsetof(PyInstanceObject, in_weakreflist) /* tp_weaklistoffset */
};
\end{verbatim}
--- 241,265 ----
/* Lots of stuff omitted for brevity... */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS /* tp_flags */
! 0, /* tp_doc */
! 0, /* tp_traverse */
! 0, /* tp_clear */
! 0, /* tp_richcompare */
! offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
};
+ \end{verbatim}
+
+ The type constructor is responsible for initializing the weak reference
+ list to \NULL:
+
+ \begin{verbatim}
+ static PyObject *
+ instance_new() {
+ /* Other initialization stuff omitted for brevity */
+
+ self->in_weakreflist = NULL;
+
+ return (PyObject *) self;
+ }
\end{verbatim}