python: Port simple libpython module to Python 3 compatible form
authorLumir Balhar <lbalhar@redhat.com>
Thu, 20 Apr 2017 13:11:58 +0000 (15:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 13 Jun 2017 20:46:14 +0000 (22:46 +0200)
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
python/modules.c
python/wscript

index 371f0d5a07acb27121c1b1c851cea9f42bb90d02..5db3dd348e2ca99b50ecacca8da28c9f71184b2b 100644 (file)
 */
 
 #include <Python.h>
+#include "py3compat.h"
 #include "includes.h"
 #include "python/modules.h"
 #include "dynconfig/dynconfig.h"
 
 static bool PySys_PathPrepend(PyObject *list, const char *path)
 {
-       PyObject *py_path = PyString_FromString(path);
+       PyObject *py_path = PyStr_FromString(path);
        if (py_path == NULL)
                return false;
 
index 623ca44b00595a013b0c3b7fc229e38123cafdba..211fac4de620c9cd21cc9103a682ef7ac87c2c38 100644 (file)
@@ -51,17 +51,10 @@ def build(bld):
                       pyembed=True,
                       enabled=bld.PYTHON_BUILD_IS_ENABLED())
 
-    bld.SAMBA_SUBSYSTEM('LIBPYTHON',
-                        source='modules.c',
-                        public_deps='',
-                        init_function_sentinel='{NULL,NULL}',
-                        deps='talloc',
-                        pyext=True,
-                        enabled=bld.PYTHON_BUILD_IS_ENABLED())
-
     for env in bld.gen_python_environments():
         pytalloc_util = bld.pyembed_libname('pytalloc-util')
         pyparam_util = bld.pyembed_libname('pyparam_util')
+        libpython = bld.pyembed_libname('LIBPYTHON')
 
         bld.SAMBA_PYTHON('python_glue',
                          source='pyglue.c',
@@ -73,6 +66,14 @@ def build(bld):
                               ''' % (pyparam_util, pytalloc_util),
                          realname='samba/_glue.so')
 
+        bld.SAMBA_SUBSYSTEM(libpython,
+                            source='modules.c',
+                            public_deps='',
+                            init_function_sentinel='{NULL,NULL}',
+                            deps='talloc',
+                            pyext=True,
+                            enabled=bld.PYTHON_BUILD_IS_ENABLED())
+
     if bld.PYTHON_BUILD_IS_ENABLED():
         for env in bld.gen_python_environments():
             # install out various python scripts for use by make test