I'm writing Python bindings for a small bit of C code.

If I have
--------------------
PyObject *t = PyTuple_New (3);
if (hit->text == NULL)
        PyTuple_SET_ITEM (t, 0, Py_None);
else
        PyTuple_SET_ITEM (t, 0, PyString_FromString(hit->text));
--------------------
then do I have to Py_INCREF the Py_None in the NULL if-branch?  But the
result from PyString_FromString is properly ref-counted, right?

Also, if I do
--------------------
PyArg_ParseTuple(first, "sO:", &keystring, &handler)
--------------------
then I don't have to manually free keystring or Py_XDECREF handler, but
to refer to the string data later, I should g_strdup (and later free my
dup), right?

Just checking.  :)

Thanks again!
Nigel
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to