From 6efb7ff98191c5f62f66be33591f674b682986ac Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Dec 2008 07:34:27 +0100 Subject: Fix various Python-related bugs. --- source4/param/param_wrap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source4/param/param_wrap.c') diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c index 6ce17957c1..596c21038e 100644 --- a/source4/param/param_wrap.c +++ b/source4/param/param_wrap.c @@ -2793,27 +2793,26 @@ SWIGINTERN struct param_opt *param_section_next_parameter(param_section *self,st struct loadparm_context *lp_from_py_object(PyObject *py_obj) { - struct loadparm_context *lp_ctx; + struct loadparm_context *lp_ctx = NULL; if (PyString_Check(py_obj)) { lp_ctx = loadparm_init(NULL); if (!lp_load(lp_ctx, PyString_AsString(py_obj))) { talloc_free(lp_ctx); + PyErr_SetString(PyExc_RuntimeError, "Unable to load file"); 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; - } + SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ); + if (lp_ctx != NULL) return lp_ctx; + lp_ctx = loadparm_init(NULL); + if (!lp_load_default(lp_ctx)) { + talloc_free(lp_ctx); + PyErr_SetString(PyExc_RuntimeError, "Unable to load default file"); + return NULL; } - - if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0) - return NULL; return lp_ctx; } -- cgit