was looking at the gimps python API, svn - gimp-pdb.c:311

GimpParam *
pygimp_param_from_tuple(PyObject *args, const GimpParamDef *ptype, int 
     PyObject *tuple, *item, *r, *g, *b, *x, *y, *w, *h;
     GimpParam *ret;
     int i, j, len;
     gint32 *i32a; gint16 *i16a; guint8 *i8a; gdouble *fa; gchar **sa;

     if (nparams == 0)
        tuple = PyTuple_New(0);
     else if (!PyTuple_Check(args) && nparams == 1)
        tuple = Py_BuildValue("(O)", args);
     else {
        tuple = args;
     if (!PyTuple_Check(tuple)) {
        PyErr_SetString(PyExc_TypeError, "wrong type of parameter");
        return NULL;

     if (PyTuple_Size(tuple) != nparams) {
        PyErr_SetString(PyExc_TypeError, "wrong number of parameters");
        return NULL;
--- snip

Notice that tuple is always created, but error values dont free, I think 
both "return NULL;"'s need a Py_DECREF(tuple); before them.

Campbell J Barton (ideasman42)
Gimp-developer mailing list

Reply via email to