From 28bf7912f0c4d94329b1ba5a22a80a7328174643 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 15 Jun 2009 12:38:16 +0000 Subject: Python Binding: fix bug of uninitialized ppos argument to PyDict_Next MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bindings/pyhton/wrapper_top.c (set_hashtable_of_pygobject): second argument (int*ppos) of PyDict_Next must be reinitialized to zero before each traversal (see Python C API http://docs.python.org/c-api/dict.html). Patch from Iban Rodríguez of the Desarrollo de Producto Electrónico, Spain. --- bindings/python/wrapper_top.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bindings/python') diff --git a/bindings/python/wrapper_top.c b/bindings/python/wrapper_top.c index e71c5fa2..4de78737 100644 --- a/bindings/python/wrapper_top.c +++ b/bindings/python/wrapper_top.c @@ -141,14 +141,15 @@ set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict) { if (! PyString_Check(key) || ! PyObject_TypeCheck(value, &PyGObjectPtrType)) { PyErr_SetString(PyExc_TypeError, - "value should be a dict," - "with string keys" + "value should be a dict, " + "with string keys " "and GObjectPtr values"); goto failure; } g_object_ref(((PyGObjectPtr*)value)->obj); } g_hash_table_remove_all (a_hash); + i = 0; while (PyDict_Next(dict, &i, &key, &value)) { char *ckey = g_strdup(PyString_AsString(key)); g_hash_table_replace (a_hash, ckey, ((PyGObjectPtr*)value)->obj); -- cgit