Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
static PyObject *py_ldb_get_firstmodule(PyLdbObject *self, void *closure)
{
- return PyLdbModule_FromModule(pyldb_Ldb_AsLdbContext(self)->modules);
+ struct ldb_module *mod = pyldb_Ldb_AsLdbContext(self)->modules;
+ if (mod == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PyLdbModule_FromModule(mod);
}
static PyGetSetDef py_ldb_getset[] = {
x = ldb.Ldb(filename())
self.assertEqual("[<ldb module 'tdb'>]", repr(x.modules()))
+ def test_firstmodule_none(self):
+ x = ldb.Ldb()
+ self.assertEqual(x.firstmodule, None)
+
+ def test_firstmodule_tdb(self):
+ x = ldb.Ldb(filename())
+ mod = x.firstmodule
+ self.assertEqual(repr(mod), "<ldb module 'tdb'>")
+
def test_search(self):
l = ldb.Ldb(filename())
self.assertEqual(len(l.search()), 0)