Py_BuildValue("(OO)",...) is documented to increment the reference
count of the objects in the arglist (and it works like documented...)

There are several places where the refcount is incremented twice.

Index: gtkmodule.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/gtkmodule.c,v
retrieving revision 1.34
diff -u -r1.34 gtkmodule.c
--- gtkmodule.c 1999/09/28 16:10:59     1.34
+++ gtkmodule.c 1999/11/10 09:52:10
@@ -3256,10 +3256,7 @@
         PyErr_SetString(PyExc_TypeError, "third argument must be callable");
         return NULL;
     }
-    Py_INCREF(func);
-    if (extra)
-       Py_INCREF(extra);
-    else
+    if (!extra)
        extra = PyTuple_New(0);
     data = Py_BuildValue("(OO)", func, extra);
     signum = gtk_signal_connect_full(PyGtk_Get(obj), name, NULL,
@@ -3281,10 +3278,7 @@
         PyErr_SetString(PyExc_TypeError, "third argument must be callable");
         return NULL;
     }
-    Py_INCREF(func);
-    if (extra)
-       Py_INCREF(extra);
-    else
+    if (!extra)
        extra = PyTuple_New(0);
     data = Py_BuildValue("(OO)", func, extra);
     signum = gtk_signal_connect_full(PyGtk_Get(obj), name, NULL,
@@ -3307,12 +3301,8 @@
         PyErr_SetString(PyExc_TypeError, "third argument must be callable");
         return NULL;
     }
-    Py_INCREF(func);
-    if (extra)
-       Py_INCREF(extra);
-    else
+    if (!extra)
        extra = PyTuple_New(0);
-    Py_INCREF(other);
     data = Py_BuildValue("(OOO)", func, extra, other);
     signum = gtk_signal_connect_full(PyGtk_Get(obj), name, NULL,
                                     (GtkCallbackMarshal)PyGtk_CallbackMarshal,
@@ -3334,12 +3324,8 @@
         PyErr_SetString(PyExc_TypeError, "third argument must be callable");
         return NULL;
     }
-    Py_INCREF(func);
-    if (extra)
-       Py_INCREF(extra);
-    else
+    if (!extra)
        extra = PyTuple_New(0);
-    Py_INCREF(other);
     data = Py_BuildValue("(OOO)", func, extra, other);
     signum = gtk_signal_connect_full(PyGtk_Get(obj), name, NULL,
                                     (GtkCallbackMarshal)PyGtk_CallbackMarshal,
@@ -3515,11 +3501,8 @@
         PyErr_SetString(PyExc_TypeError, "second arg not callable");
         return NULL;
     }
-    if (cbargs)
-       Py_INCREF(cbargs);
-    else
+    if (!cbargs)
        cbargs = PyTuple_New(0);
-    Py_INCREF(callback);
     return PyInt_FromLong(gtk_timeout_add_full(interval, NULL,
         (GtkCallbackMarshal)PyGtk_HandlerMarshal,
        Py_BuildValue("(OO)", callback, cbargs),
@@ -3537,11 +3520,8 @@
         PyErr_SetString(PyExc_TypeError, "arg not callable");
         return NULL;
     }
-    if (cbargs)
-       Py_INCREF(cbargs);
-    else
+    if (!cbargs)
        cbargs = PyTuple_New(0);
-    Py_INCREF(callback);
     return PyInt_FromLong(gtk_idle_add_full(GTK_PRIORITY_DEFAULT, NULL,
         (GtkCallbackMarshal)PyGtk_HandlerMarshal,
        Py_BuildValue("(OO)", callback, cbargs),
@@ -3585,11 +3565,8 @@
         PyErr_SetString(PyExc_TypeError, "2nd arg not callable");
         return NULL;
     }
-    if (cbargs)
+    if (!cbargs)
        Py_INCREF(cbargs);
-    else
-       cbargs = PyTuple_New(0);
-    Py_INCREF(callback);
     return PyInt_FromLong(gtk_quit_add_full(main_level, NULL,
         (GtkCallbackMarshal)PyGtk_HandlerMarshal,
        Py_BuildValue("(OO)", callback, cbargs),
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to