[farsight2/master] Make python bindings deal with empty lists correctly
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:23:05 PST 2008
---
python/pyfarsight.override | 23 ++++++++++-------------
1 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/python/pyfarsight.override b/python/pyfarsight.override
index 120f172..81782a6 100644
--- a/python/pyfarsight.override
+++ b/python/pyfarsight.override
@@ -102,8 +102,8 @@ _fs_candidate_list_to_value (GValue *value, PyObject *obj)
(StructCopyFunc) fs_candidate_copy);
}
-static GList *
-_fs_codec_list_from_pysequence (PyObject *obj)
+static gboolean
+_fs_codec_list_from_pysequence (PyObject *obj, GList **list)
{
GList *codecs = NULL;
gint i;
@@ -112,7 +112,7 @@ _fs_codec_list_from_pysequence (PyObject *obj)
{
PyErr_SetString (PyExc_TypeError,
"The parameter must be a List of FsCodec");
- return NULL;
+ return FALSE;
}
for (i = 0; i < PySequence_Size (obj); i++)
@@ -123,7 +123,7 @@ _fs_codec_list_from_pysequence (PyObject *obj)
{
PyErr_SetString(PyExc_TypeError,
"The parameter must be a List of FsCodec");
- return NULL;
+ return FALSE;
}
}
@@ -134,7 +134,8 @@ _fs_codec_list_from_pysequence (PyObject *obj)
codecs = g_list_append (codecs, pyg_boxed_get (item, FsCodec));
}
- return codecs;
+ *list = codecs;
+ return TRUE;
}
%%
@@ -625,8 +626,7 @@ _wrap_fs_stream_set_remote_codecs (PyGObject *self, PyObject *arg)
return NULL;
}
- codecs = _fs_codec_list_from_pysequence (arg);
- if (codecs == NULL)
+ if (!_fs_codec_list_from_pysequence (arg, &codecs))
return NULL;
Py_BEGIN_ALLOW_THREADS
@@ -649,8 +649,7 @@ _wrap_fs_session_set_local_codecs_config (PyGObject *self, PyObject *arg)
GError *error = NULL;
GList *codecs = NULL;
- codecs = _fs_codec_list_from_pysequence (arg);
- if (codecs == NULL)
+ if (!_fs_codec_list_from_pysequence (arg, &codecs))
return NULL;
Py_BEGIN_ALLOW_THREADS
@@ -684,12 +683,10 @@ _wrap_fs_codec_list_are_equal(PyGObject *self, PyObject *args, PyObject *kwargs)
if (pylist1 == pylist2)
return PyBool_FromLong (TRUE);
- list1 = _fs_codec_list_from_pysequence (pylist1);
- if (!list1)
+ if (!_fs_codec_list_from_pysequence (pylist1, &list1))
return NULL;
- list2 = _fs_codec_list_from_pysequence (pylist2);
- if (!list2)
+ if (!_fs_codec_list_from_pysequence (pylist2, &list2))
{
g_list_free (list1);
return NULL;
--
1.5.6.5
More information about the farsight-commits
mailing list