summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2011-06-11 16:57:02 +0400
committerMatthieu Patou <mat@samba.org>2011-06-19 23:21:07 +0200
commit02970f41a27bd4614d6aedf0fe337619b34310db (patch)
tree2f8e11aaaa641d3365d7dd8b5dc9be1123f901d0
parent5290faca7a5ae5f3f0309a42586768a5c93bfb9d (diff)
downloadsamba-02970f41a27bd4614d6aedf0fe337619b34310db.tar.gz
samba-02970f41a27bd4614d6aedf0fe337619b34310db.tar.bz2
samba-02970f41a27bd4614d6aedf0fe337619b34310db.zip
py-ldb: allow dictionnary like usage (ie. e.get("myattribute", defVal)
-rw-r--r--source4/lib/ldb/pyldb.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 61662f6763..b568bc2ccd 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -2442,15 +2442,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;
}