0012-python-return-NULL-if-set_hashtable_of_pygobject-fai.patch
bindings/python/lang.py | ||
---|---|---|
828 | 828 |
elif is_hashtable(m): |
829 | 829 |
el_type = element_type(m) |
830 | 830 |
if is_object(el_type): |
831 |
print_(' set_hashtable_of_pygobject(this->%s, cvt_value);' % name, file=fd)
|
|
831 |
print_(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd)
|
|
832 | 832 |
else: |
833 | 833 |
print_(' set_hashtable_of_strings(this->%s, cvt_value);' % name, file=fd) |
834 | 834 |
elif is_object(m): |
bindings/python/wrapper_top.c | ||
---|---|---|
89 | 89 |
G_GNUC_UNUSED static PyObject* get_dict_from_hashtable_of_objects(GHashTable *value); |
90 | 90 |
G_GNUC_UNUSED static PyObject* get_dict_from_hashtable_of_strings(GHashTable *value); |
91 | 91 |
G_GNUC_UNUSED static PyObject* PyGObjectPtr_New(GObject *obj); |
92 |
G_GNUC_UNUSED static void set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict);
|
|
92 |
G_GNUC_UNUSED static int set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict);
|
|
93 | 93 |
G_GNUC_UNUSED static void set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict); |
94 | 94 |
G_GNUC_UNUSED static void set_list_of_strings(GList **a_list, PyObject *seq); |
95 | 95 |
G_GNUC_UNUSED static void set_list_of_xml_nodes(GList **a_list, PyObject *seq); |
... | ... | |
235 | 235 |
* values from the hash, so if there are somme common |
236 | 236 |
* values with RefCoun = 1 they won't be deallocated. |
237 | 237 |
* */ |
238 |
static void |
|
238 |
int |
|
239 | 239 |
set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict) { |
240 | 240 |
PyObject *key, *value; |
241 | 241 |
Py_ssize_t i; |
242 | 242 | |
243 | 243 |
if (! a_hash) { |
244 | 244 |
PyErr_SetString(PyExc_TypeError, "hashtable does not exist"); |
245 |
return; |
|
245 |
return 0;
|
|
246 | 246 |
} |
247 | 247 |
if (dict != Py_None && ! PyDict_Check(dict)) { |
248 | 248 |
PyErr_SetString(PyExc_TypeError, "value should be a frozen dict"); |
249 |
return; |
|
249 |
return 0;
|
|
250 | 250 |
} |
251 | 251 |
i = 0; |
252 | 252 |
// Increase ref count of common object between old and new |
... | ... | |
269 | 269 |
g_hash_table_replace (a_hash, g_strdup(ckey), ((PyGObjectPtr*)value)->obj); |
270 | 270 |
PyStringFree(ckey); |
271 | 271 |
} |
272 |
return; |
|
272 |
return 1;
|
|
273 | 273 |
failure: |
274 | 274 |
i = 0; |
275 | 275 |
while (PyDict_Next(dict, &i, &key, &value)) { |
... | ... | |
277 | 277 |
break; |
278 | 278 |
g_object_unref((PyGObjectPtr*)value); |
279 | 279 |
} |
280 |
return 0; |
|
280 | 281 |
} |
281 | 282 | |
282 | 283 |
static void |
283 |
- |