#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;
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)
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)
ret = py_lp_ctx_get_helper(self->ptr, section_name, param_name);
if (ret == NULL)
- return Py_None;
+ Py_RETURN_NONE;
return ret;
}
return NULL;
}
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *py_lp_ctx_private_path(py_talloc_Object *self, PyObject *args)
.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)) {
lp_ctx = loadparm_init(NULL);
if (!lp_load(lp_ctx, PyString_AsString(py_obj))) {
talloc_free(lp_ctx);
+ PyErr_Format(PyExc_RuntimeError,
+ "Unable to load %s", PyString_AsString(py_obj));
return NULL;
}
return lp_ctx;
if (py_obj == Py_None) {
lp_ctx = loadparm_init(NULL);
- if (!lp_load_default(lp_ctx)) {
- talloc_free(lp_ctx);
- return NULL;
- }
+ /* We're not checking that loading the file succeeded *on purpose */
+ lp_load_default(lp_ctx);
return lp_ctx;
}