view finch/libgnt/pygnt/common.c @ 19490:79dbe5fc2097

propagate from branch 'im.pidgin.pidgin' (head 671cfe949215447db0da7081a7e1501693ab4f98) to branch 'im.pidgin.soc.2007.certmgr' (head 32fa8216700560f0b249af58a4bad103e214aa3f)
author William Ehlhardt <williamehlhardt@gmail.com>
date Mon, 20 Aug 2007 02:49:47 +0000
parents 5e1412f4e67a
children
line wrap: on
line source

#include "common.h"

PyObject *
create_pyobject_from_string_list(GList *list)
{
	PyObject *py_list;
	if (list == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
	if ((py_list = PyList_New(0)) == NULL) {
		g_list_foreach(list, (GFunc)g_free, NULL);
		g_list_free(list);
		return NULL;
	}
	while (list) {
		PyObject *obj = PyString_FromString(list->data);
		PyList_Append(py_list, obj);
		Py_DECREF(obj);
		g_free(list->data);
		list = g_list_delete_link(list, list);
	}
	return py_list;
}