python: Remove const from PyList_AsStringList()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 21 Jul 2023 02:32:46 +0000 (14:32 +1200)
committerJule Anger <janger@samba.org>
Fri, 4 Aug 2023 07:02:15 +0000 (07:02 +0000)
The returned strings are not owned by python, so need not be const.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15289

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 5afd206d1d8f0344a2f1fa7a238204d1fb164eda)

python/modules.c
python/modules.h
source4/auth/pyauth.c

index 83dc91c08a1303b0c7300b7f5a5c4021dc96c323..ca563ff07d2db1ddf6417e770b1c494243fce26c 100644 (file)
@@ -72,16 +72,16 @@ error:
        return false;
 }
 
-const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list, 
-                                const char *paramname)
+char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
+                          const char *paramname)
 {
-       const char **ret;
+       char **ret;
        Py_ssize_t i;
        if (!PyList_Check(list)) {
                PyErr_Format(PyExc_TypeError, "%s is not a list", paramname);
                return NULL;
        }
-       ret = talloc_array(NULL, const char *, PyList_Size(list)+1);
+       ret = talloc_array(NULL, char *, PyList_Size(list)+1);
        if (ret == NULL) {
                PyErr_NoMemory();
                return NULL;
index 331adde0230dca839cdeaf048e698756af49f6bf..356937d71f9237fe3163f2cedb08b7ee5bcbaa91 100644 (file)
@@ -26,8 +26,8 @@ bool py_update_path(void);
 /* discard signature of 'func' in favour of 'target_sig' */
 #define PY_DISCARD_FUNC_SIG(target_sig, func) (target_sig)(void(*)(void))func
 
-const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
-                                const char *paramname);
+char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
+                          const char *paramname);
 
 #endif /* __SAMBA_PYTHON_MODULES_H__ */ 
 
index ee36b5e5efa62809dff4918ae9db535ae96dc423..b41108b70726eb76599729dd9ca5bc0eb8f68a2e 100644 (file)
@@ -367,7 +367,7 @@ static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObjec
        struct tevent_context *ev;
        struct ldb_context *ldb = NULL;
        NTSTATUS nt_status;
-       const char **methods;
+       const char *const *methods;
 
        const char *const kwnames[] = {"lp_ctx", "ldb", "methods", NULL};
 
@@ -413,7 +413,7 @@ static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObjec
                    mem_ctx, ev, NULL, lp_ctx, &auth_context);
        } else {
                if (py_methods != Py_None) {
-                       methods = PyList_AsStringList(mem_ctx, py_methods, "methods");
+                       methods = (const char * const *)PyList_AsStringList(mem_ctx, py_methods, "methods");
                        if (methods == NULL) {
                                talloc_free(mem_ctx);
                                return NULL;