[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Tue May 5 11:25:03 UTC 2020
The branch, master has been updated
via 0847f56f243 pytdb tests: add test for storev()
via 4d42497441c pytdb: add python binding for storev()
from 29cbfd0ba39 s3: smbd: Add a dirfsp parameter to smbd_calculate_maximum_allowed_access().
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0847f56f243bc9b09cfc9b2b14c3b2454f7bdaac
Author: Jule Anger <ja at sernet.de>
Date: Tue Apr 28 17:01:11 2020 +0200
pytdb tests: add test for storev()
Signed-off-by: Jule Anger <ja at sernet.de>
Reviewed-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Tue May 5 11:24:52 UTC 2020 on sn-devel-184
commit 4d42497441c8e5308c6578845c3c5e858bc63fbf
Author: Jule Anger <ja at sernet.de>
Date: Tue Apr 28 17:00:46 2020 +0200
pytdb: add python binding for storev()
Signed-off-by: Jule Anger <ja at sernet.de>
Reviewed-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Volker Lendecke <vl at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/tdb/pytdb.c | 49 ++++++++++++++++++++++++++++++++++++++++++
lib/tdb/python/tests/simple.py | 4 ++++
2 files changed, 53 insertions(+)
Changeset truncated at 500 lines:
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 5ff1ef83117..69da98c34d4 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -381,6 +381,53 @@ static PyObject *obj_store(PyTdbObject *self, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *obj_storev(PyTdbObject *self, PyObject *args)
+{
+ TDB_DATA key, *values, value;
+ int ret;
+ int flag = TDB_REPLACE;
+ Py_ssize_t num_values, i;
+ PyObject *py_key, *py_values, *py_value;
+
+ PyErr_TDB_RAISE_IF_CLOSED(self);
+
+ if (!PyArg_ParseTuple(
+ args, "OO!|i", &py_key, &PyList_Type, &py_values, &flag)) {
+ return NULL;
+ }
+
+ num_values = PyList_Size(py_values);
+
+ key = PyBytes_AsTDB_DATA(py_key);
+ if (key.dptr == NULL) {
+ return NULL;
+ }
+
+ if (SSIZE_MAX/sizeof(TDB_DATA) < num_values) {
+ PyErr_SetFromErrno(PyExc_OverflowError);
+ return NULL;
+ }
+ values = malloc(sizeof(TDB_DATA) * num_values);
+ if (values == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ for (i=0; i<num_values; i++) {
+ py_value = PyList_GetItem(py_values, i);
+ value = PyBytes_AsTDB_DATA(py_value);
+ if (!value.dptr) {
+ free(values);
+ return NULL;
+ }
+ values[i] = value;
+ }
+
+ ret = tdb_storev(self->ctx, key, values, num_values, flag);
+ free(values);
+ PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
+ Py_RETURN_NONE;
+}
+
static PyObject *obj_add_flags(PyTdbObject *self, PyObject *args)
{
unsigned flags;
@@ -525,6 +572,8 @@ static PyMethodDef tdb_object_methods[] = {
#endif
{ "store", (PyCFunction)obj_store, METH_VARARGS, "S.store(key, data, flag=REPLACE) -> None"
"Store data." },
+ { "storev", (PyCFunction)obj_storev, METH_VARARGS, "S.storev(key, data, flag=REPLACE) -> None"
+ "Store several data." },
{ "add_flags", (PyCFunction)obj_add_flags, METH_VARARGS, "S.add_flags(flags) -> None" },
{ "remove_flags", (PyCFunction)obj_remove_flags, METH_VARARGS, "S.remove_flags(flags) -> None" },
#if PY_MAJOR_VERSION >= 3
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 312d587fcde..f7ab0243644 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -113,6 +113,10 @@ class SimpleTdbTests(TestCase):
self.tdb.store(b"bar", b"bla")
self.assertEqual(b"bla", self.tdb.get(b"bar"))
+ def test_storev(self):
+ self.tdb.storev(b"bar", [b"first", b"second", b"third"])
+ self.assertEqual(b"firstsecondthird", self.tdb.get(b"bar"))
+
def test_getitem(self):
self.tdb[b"bar"] = b"foo"
self.tdb.reopen()
--
Samba Shared Repository
More information about the samba-cvs
mailing list