Updated documentation to:
- point out the importance of reassigning data members before
assigning thier values
- correct my missconception about return values from visitprocs. Sigh.
- mention the labor saving Py_VISIT and Py_CLEAR macros.
diff --git a/Doc/ext/noddy2.c b/Doc/ext/noddy2.c
index 03fe288..2683e8b 100644
--- a/Doc/ext/noddy2.c
+++ b/Doc/ext/noddy2.c
@@ -46,7 +46,7 @@
static int
Noddy_init(Noddy *self, PyObject *args, PyObject *kwds)
{
- PyObject *first=NULL, *last=NULL;
+ PyObject *first=NULL, *last=NULL, *tmp;
static char *kwlist[] = {"first", "last", "number", NULL};
@@ -56,15 +56,17 @@
return -1;
if (first) {
- Py_XDECREF(self->first);
+ tmp = self->first;
Py_INCREF(first);
self->first = first;
+ Py_XDECREF(tmp);
}
if (last) {
- Py_XDECREF(self->last);
+ tmp = self->last;
Py_INCREF(last);
self->last = last;
+ Py_XDECREF(tmp);
}
return 0;