From c5266f69670f98f2811bd0504ceb98d31b847851 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 19 Jun 2020 21:06:11 +0200 Subject: [PATCH 5/6] python: fix warning about discarded const modifier (#44287) --- bindings/python/wrapper_top.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bindings/python/wrapper_top.c b/bindings/python/wrapper_top.c index 7c98ef1e..5a7fd8c3 100644 --- a/bindings/python/wrapper_top.c +++ b/bindings/python/wrapper_top.c @@ -262,8 +262,9 @@ set_hashtable_of_pygobject(GHashTable *a_hash, PyObject *dict) { g_hash_table_remove_all (a_hash); i = 0; while (PyDict_Next(dict, &i, &key, &value)) { - char *ckey = PyString_AsString(key); - g_hash_table_replace (a_hash, ckey, ((PyGObjectPtr*)value)->obj); + const char *ckey = PyString_AsString(key); + g_hash_table_replace (a_hash, g_strdup(ckey), ((PyGObjectPtr*)value)->obj); + PyStringFree(ckey); } return; failure: @@ -305,9 +306,11 @@ set_hashtable_of_strings(GHashTable *a_hash, PyObject *dict) g_hash_table_remove_all (a_hash); i = 0; while (PyDict_Next(dict, &i, &key, &value)) { - char *ckey = PyString_AsString(key); - char *cvalue = PyString_AsString(value); + const char *ckey = PyString_AsString(key); + const char *cvalue = PyString_AsString(value); g_hash_table_insert (a_hash, g_strdup(ckey), g_strdup(cvalue)); + PyStringFree(ckey); + PyStringFree(cvalue); } failure: return; @@ -403,7 +406,7 @@ failure: static xmlNode* get_xml_node_from_pystring(PyObject *string) { - char *utf8 = NULL; + const char *utf8 = NULL; Py_ssize_t size; xmlNode *xml_node; utf8 = get_pystring(string, &size); -- 2.26.2