s3/s4 build: Fix Py_RETURN_NONE to work with python versions < 2.4
[jra/samba/.git] / source4 / param / pyparam.c
index 0cf651dd7c66bc77f6b711c77fb68ef46ba24ef0..1eef02ba39e301611fa86469a8ba9be026d0eea6 100644 (file)
 #include "includes.h"
 #include "param/param.h"
 #include "param/loadparm.h"
+#include "../lib/util/python_util.h"
 #include "pytalloc.h"
 
+/* There's no Py_ssize_t in 2.4, apparently */
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
+typedef int Py_ssize_t;
+typedef inquiry lenfunc;
+#endif
+
 #define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_ptr(obj)
 
 PyAPI_DATA(PyTypeObject) PyLoadparmContext;
@@ -144,7 +151,7 @@ static PyObject *py_lp_ctx_load(py_talloc_Object *self, PyObject *args)
                PyErr_Format(PyExc_RuntimeError, "Unable to load file %s", filename);
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *py_lp_ctx_load_default(py_talloc_Object *self)
@@ -156,7 +163,7 @@ static PyObject *py_lp_ctx_load_default(py_talloc_Object *self)
                PyErr_SetString(PyExc_RuntimeError, "Unable to load default file");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *py_lp_ctx_get(py_talloc_Object *self, PyObject *args)
@@ -169,7 +176,7 @@ static PyObject *py_lp_ctx_get(py_talloc_Object *self, PyObject *args)
 
        ret = py_lp_ctx_get_helper(self->ptr, section_name, param_name);
        if (ret == NULL)
-               return Py_None;
+               Py_RETURN_NONE;
        return ret;
 }
 
@@ -204,7 +211,7 @@ static PyObject *py_lp_ctx_set(py_talloc_Object *self, PyObject *args)
                return NULL;
         }
 
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *py_lp_ctx_private_path(py_talloc_Object *self, PyObject *args)
@@ -310,7 +317,7 @@ PyTypeObject PyLoadparmService = {
        .tp_flags = Py_TPFLAGS_DEFAULT,
 };
 
-struct loadparm_context *lp_from_py_object(PyObject *py_obj)
+_PUBLIC_ struct loadparm_context *lp_from_py_object(PyObject *py_obj)
 {
     struct loadparm_context *lp_ctx;
     if (PyString_Check(py_obj)) {