From ef45e845f08a8f4c637fa636ebb92a0ecfe9b99e Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sat, 11 Jun 2011 16:57:02 +0400 Subject: [PATCH] py-ldb: allow dictionnary like usage (ie. e.get("myattribute", defVal) --- source4/lib/ldb/pyldb.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 88ae70a..1a73608 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -2444,15 +2444,20 @@ static PyObject *py_ldb_msg_getitem(PyLdbMessageObject *self, PyObject *py_name) static PyObject *py_ldb_msg_get(PyLdbMessageObject *self, PyObject *args) { - PyObject *name, *ret; - if (!PyArg_ParseTuple(args, "O", &name)) + PyObject *name, *ret, *retobj; + retobj = NULL; + if (!PyArg_ParseTuple(args, "O|O", &name, &retobj)) return NULL; ret = py_ldb_msg_getitem_helper(self, name); if (ret == NULL) { if (PyErr_Occurred()) return NULL; - Py_RETURN_NONE; + if (retobj != NULL) { + return retobj; + } else { + Py_RETURN_NONE; + } } return ret; } -- 1.7.4.1