lib-pyldb: Throw exception when we can't create MessageElement object
authorKamen Mazdrashki <kamenim@samba.org>
Mon, 10 Nov 2014 21:59:07 +0000 (22:59 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 Nov 2014 04:04:07 +0000 (05:04 +0100)
At the moment we return an error, but no exception and it is
hard to instantly see what the problem is from Python

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index efac7b1be65652099dd57445c289dc21bb84d508..40c802fd9afece980bda9a757dcbb283c19f4b14 100644 (file)
@@ -2352,6 +2352,8 @@ static struct ldb_message_element *PyObject_AsMessageElement(
                                (uint8_t *)PyString_AsString(obj), me->values[i].length+1);
                }
        } else {
+               PyErr_Format(PyExc_TypeError,
+                            "String or List type expected for '%s' attribute", attr_name);
                talloc_free(me);
                me = NULL;
        }