python3 port for param module
authorNoel Power <noel.power@suse.com>
Mon, 5 Feb 2018 11:39:58 +0000 (11:39 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 5 Apr 2018 06:59:08 +0000 (08:59 +0200)
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>
source3/param/pyparam.c
source3/param/wscript_build

index ddd17ca4b5f19dc25358f55ace44018f33fe0b5c..4f80a0ef864f2881b247900e35de6bca3a59268a 100644 (file)
@@ -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;
 }
index c60e917dba0ab8f796504af0df8c662c30070f24..c9c42a356250e1a72b340b05febe138580a71a57 100644 (file)
@@ -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',