summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-02-05 11:39:58 +0000
committerAndrew Bartlett <abartlet@samba.org>2018-04-05 08:59:08 +0200
commitac888471b05e9529b84c221177ec820bde1be893 (patch)
tree85974836adadc1bf3af16943d1171e65eae6d1d5 /source3/param
parent7ad012d4118a1031be3111ee5305109a9d3117d0 (diff)
downloadsamba-ac888471b05e9529b84c221177ec820bde1be893.tar.gz
python3 port for param module
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/pyparam.c22
-rw-r--r--source3/param/wscript_build3
2 files changed, 18 insertions, 7 deletions
diff --git a/source3/param/pyparam.c b/source3/param/pyparam.c
index ddd17ca4b5f..4f80a0ef864 100644
--- a/source3/param/pyparam.c
+++ b/source3/param/pyparam.c
@@ -19,6 +19,7 @@
#include <Python.h>
#include "includes.h"
+#include "python/py3compat.h"
#include "param/param.h"
#include "param/loadparm.h"
#include "lib/talloc/pytalloc.h"
@@ -66,22 +67,31 @@ static PyMethodDef pyparam_methods[] = {
{ NULL }
};
-void initparam(void)
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "param",
+ .m_doc = "Parsing and writing Samba3 configuration files.",
+ .m_size = -1,
+ .m_methods = pyparam_methods,
+};
+
+MODULE_INIT_FUNC(param)
{
- PyObject *m, *mod;
+ PyObject *m = NULL, *mod = NULL;
- m = Py_InitModule3("param", pyparam_methods, "Parsing and writing Samba3 configuration files.");
+ m = PyModule_Create(&moduledef);
if (m == NULL)
- return;
+ return NULL;
mod = PyImport_ImportModule("samba.param");
if (mod == NULL) {
- return;
+ return NULL;
}
loadparm_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "LoadParm");
Py_DECREF(mod);
if (loadparm_Type == NULL) {
- return;
+ return NULL;
}
+ return m;
}
diff --git a/source3/param/wscript_build b/source3/param/wscript_build
index c60e917dba0..c9c42a35625 100644
--- a/source3/param/wscript_build
+++ b/source3/param/wscript_build
@@ -14,7 +14,8 @@ bld.SAMBA_GENERATOR('s3_param_proto_h',
group='build_source',
rule='${PYTHON} ${SRC[0].abspath(env)} --file ${SRC[1].abspath(env)} --output ${TGT} --mode=S3PROTO')
-bld.SAMBA3_PYTHON('pys3param',
+for env in bld.gen_python_environments():
+ bld.SAMBA3_PYTHON('pys3param',
source='pyparam.c',
deps='smbconf',
public_deps='samba-hostconfig pytalloc-util talloc',