python: return NULL if set_hashtable_of_strings fails (#44287)
This commit is contained in:
parent
57ee8d2f2a
commit
ed528ce26a
|
@ -833,7 +833,7 @@ register_constants(PyObject *d)
|
|||
if is_object(el_type):
|
||||
print_(' RETURN_IF_FAIL(set_hashtable_of_pygobject(this->%s, cvt_value));' % name, file=fd)
|
||||
else:
|
||||
print_(' set_hashtable_of_strings(this->%s, cvt_value);' % name, file=fd)
|
||||
print_(' RETURN_IF_FAIL(set_hashtable_of_strings(this->%s, cvt_value));' % name, file=fd)
|
||||
elif is_object(m):
|
||||
print_(' set_object_field((GObject**)&this->%s, cvt_value);' % name, file=fd)
|
||||
else:
|
||||
|
@ -1002,7 +1002,7 @@ register_constants(PyObject *d)
|
|||
if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)):
|
||||
|
||||
print_(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd)
|
||||
print_(' set_hashtable_of_strings(%s, cvt_%s);' % (arg[1], arg[1]), file=fd)
|
||||
print_(' EXIT_IF_FAIL(set_hashtable_of_strings(%s, cvt_%s));' % (arg[1], arg[1]), file=fd)
|
||||
elif f == 'O':
|
||||
if is_optional(arg):
|
||||
print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd)
|
||||
|
|
|
@ -90,7 +90,7 @@ G_GNUC_UNUSED static PyObject* get_dict_from_hashtable_of_objects(GHashTable *va
|
|||
G_GNUC_UNUSED static PyObject* get_dict_from_hashtable_of_strings(GHashTable *value);
|
||||
G_GNUC_UNUSED static PyObject* PyGObjectPtr_New(GObject *obj);
|
||||
G_GNUC_UNUSED static int set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict);
|
||||
G_GNUC_UNUSED static void set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict);
|
||||
G_GNUC_UNUSED static int set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict);
|
||||
G_GNUC_UNUSED static void set_list_of_strings(GList **a_list, PyObject *seq);
|
||||
G_GNUC_UNUSED static void set_list_of_xml_nodes(GList **a_list, PyObject *seq);
|
||||
G_GNUC_UNUSED static void set_list_of_pygobject(GList **a_list, PyObject *seq);
|
||||
|
@ -280,7 +280,7 @@ failure:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict)
|
||||
{
|
||||
PyObject *key, *value;
|
||||
|
@ -288,11 +288,11 @@ set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict)
|
|||
|
||||
if (! a_hash) {
|
||||
PyErr_SetString(PyExc_TypeError, "hashtable does not exist");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
if (dict != Py_None && ! PyDict_Check(dict)) {
|
||||
PyErr_SetString(PyExc_TypeError, "value should be a frozen dict");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
i = 0;
|
||||
// Increase ref count of common object between old and new
|
||||
|
@ -316,8 +316,9 @@ set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict)
|
|||
PyStringFree(ckey);
|
||||
PyStringFree(cvalue);
|
||||
}
|
||||
return 1;
|
||||
failure:
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set the GList* pointer, pointed by a_list, to a pointer on a new GList
|
||||
|
|
Loading…
Reference in New Issue