pyldb: py_ldb_msg_keys() uses PyErr_LDB_MESSAGE_OR_RAISE
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 15 Mar 2024 00:50:40 +0000 (13:50 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 05:13:32 +0000 (05:13 +0000)
We change the [unused, because it always cast] signature of
py_ldb_msg_iter() in the same commit, because that is just a wrapper
around _keys() and this maintains bisectability with the least fuss.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index 46add1e0c41d134c70572683a342486b5ccf242a..eeba4470277207341fcfdbe3176843e52c32d162 100644 (file)
@@ -3711,12 +3711,16 @@ static PyObject *py_ldb_msg_remove_attr(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
-static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self,
+static PyObject *py_ldb_msg_keys(PyObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       struct ldb_message *msg = pyldb_Message_AsMessage(self);
+       struct ldb_message *msg = NULL;
        Py_ssize_t i, j = 0;
-       PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
+       PyObject *obj = NULL;
+
+       PyErr_LDB_MESSAGE_OR_RAISE(self, msg);
+
+       obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
        if (obj == NULL) {
                return NULL;
        }
@@ -3983,7 +3987,7 @@ static PyMethodDef py_ldb_msg_methods[] = {
        {0},
 };
 
-static PyObject *py_ldb_msg_iter(PyLdbMessageObject *self)
+static PyObject *py_ldb_msg_iter(PyObject *self)
 {
        PyObject *list, *iter;