From: Douglas Bagnall Date: Wed, 14 Feb 2024 01:22:53 +0000 (+1300) Subject: pyldb: try to turn ldb_string_to_time() errors into exceptions X-Git-Tag: tdb-1.4.11~1650 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfba074d2f41e70ce743ce7e216c498ab5bd977a;p=thirdparty%2Fsamba.git pyldb: try to turn ldb_string_to_time() errors into exceptions Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 5faf5f1fe69..23637a6b2a2 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -4779,10 +4779,17 @@ static PyObject *py_timestring(PyObject *module, PyObject *args) static PyObject *py_string_to_time(PyObject *module, PyObject *args) { char *str; - if (!PyArg_ParseTuple(args, "s", &str)) + time_t t; + if (!PyArg_ParseTuple(args, "s", &str)) { return NULL; + } + t = ldb_string_to_time(str); - return PyLong_FromLong(ldb_string_to_time(str)); + if (t == 0 && errno != 0) { + PyErr_SetFromErrno(PyExc_ValueError); + return NULL; + } + return PyLong_FromLong(t); } static PyObject *py_valid_attr_name(PyObject *self, PyObject *args)