diff options
author | John Mulligan <jmulligan@redhat.com> | 2022-04-23 14:19:59 -0400 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-05-06 17:16:30 +0000 |
commit | fcd50ea4ab4cc2f4f7cf7f21da3092cd107530ad (patch) | |
tree | 5caa3981870a1552bee8d320459e55f3b957f720 /lib/smbconf | |
parent | f74d163ef088eb279110dfc872a18a2fc0d8fb71 (diff) | |
download | samba-fcd50ea4ab4cc2f4f7cf7f21da3092cd107530ad.tar.gz |
lib/smbconf: add a python function for raising smbconf exceptions
The previous implementation in C was private to the module. Add
a small python wrapper function so that a different python module
may reuse the implementation.
The python level function is prefixed with "_" to mark it as
"private". Only future cooperating modules in the samba sources
should make use of it.
The function is shared at the python level as per the recommendation:
https://stackoverflow.com/a/2136670
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'lib/smbconf')
-rw-r--r-- | lib/smbconf/pysmbconf.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/smbconf/pysmbconf.c b/lib/smbconf/pysmbconf.c index 5250a03684f..efb11d0432c 100644 --- a/lib/smbconf/pysmbconf.c +++ b/lib/smbconf/pysmbconf.c @@ -365,9 +365,24 @@ static PyObject *py_init_txt(PyObject * module, PyObject * args) return (PyObject *) obj; } +static PyObject *py_smbconf_error(PyObject * module, PyObject * args) +{ + sbcErr errcode; + + if (!PyArg_ParseTuple(args, "i", &errcode)) { + return NULL; + } + + /* this always raises an exception. it doesn't return the exception. */ + py_raise_SMBConfError(errcode); + return NULL; +} + static PyMethodDef pysmbconf_methods[] = { { "init_txt", (PyCFunction) py_init_txt, METH_VARARGS, "Return an SMBConf object for the given text config file." }, + { "_smbconf_error", (PyCFunction) py_smbconf_error, METH_VARARGS, + "Raise an SMBConfError based on the given error code." }, { 0 }, }; |