summaryrefslogtreecommitdiff
path: root/lib/tdb2
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 08:13:27 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 08:13:27 +0930
commitc5c0a4d3315d10921f2d4514724da045edbda296 (patch)
tree3d5f78273237c1586385d76a027b6e7e76f3dc43 /lib/tdb2
parent2237daed7e4c6c38241bc07383ed1a421abe8d6c (diff)
downloadsamba-c5c0a4d3315d10921f2d4514724da045edbda296.tar.gz
samba-c5c0a4d3315d10921f2d4514724da045edbda296.tar.bz2
samba-c5c0a4d3315d10921f2d4514724da045edbda296.zip
tdb2: fix return handling in pytdb wrapper.
tdb_close() does genuinely return non-zero, not an error code, even in tdb2. And tdb_exists() returns true or false, not an error code. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb2')
-rw-r--r--lib/tdb2/pytdb.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/tdb2/pytdb.c b/lib/tdb2/pytdb.c
index c03f00d58c..98ce4232a9 100644
--- a/lib/tdb2/pytdb.c
+++ b/lib/tdb2/pytdb.c
@@ -173,12 +173,15 @@ static PyObject *obj_unlockall_read(PyTdbObject *self)
static PyObject *obj_close(PyTdbObject *self)
{
- enum TDB_ERROR ret;
+ int ret;
if (self->closed)
Py_RETURN_NONE;
ret = tdb_close(self->ctx);
self->closed = true;
- PyErr_TDB_ERROR_IS_ERR_RAISE(ret);
+ if (ret != 0) {
+ PyErr_SetTDBError(TDB_ERR_IO);
+ return NULL;
+ }
Py_RETURN_NONE;
}
@@ -265,17 +268,16 @@ static PyObject *obj_delete(PyTdbObject *self, PyObject *args)
static PyObject *obj_has_key(PyTdbObject *self, PyObject *args)
{
TDB_DATA key;
- enum TDB_ERROR ret;
PyObject *py_key;
if (!PyArg_ParseTuple(args, "O", &py_key))
return NULL;
key = PyString_AsTDB_DATA(py_key);
- ret = tdb_exists(self->ctx, key);
- if (ret == TDB_ERR_NOEXIST)
- return Py_False;
- PyErr_TDB_ERROR_IS_ERR_RAISE(ret);
- return Py_True;
+ if (tdb_exists(self->ctx, key))
+ return Py_True;
+ if (tdb_error(self->ctx) != TDB_ERR_NOEXIST)
+ PyErr_TDB_ERROR_IS_ERR_RAISE(tdb_error(self->ctx));
+ return Py_False;
}
static PyObject *obj_store(PyTdbObject *self, PyObject *args)