diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-12-21 07:34:27 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-12-21 07:34:27 +0100 |
commit | 6efb7ff98191c5f62f66be33591f674b682986ac (patch) | |
tree | edd2a761bf370b3e2cdb2ebd3015e4e5814439e8 /source4/param/param_wrap.c | |
parent | f36ff0bac29a0e26db8ac0994d046611e3704dd0 (diff) | |
download | samba-6efb7ff98191c5f62f66be33591f674b682986ac.tar.gz samba-6efb7ff98191c5f62f66be33591f674b682986ac.tar.bz2 samba-6efb7ff98191c5f62f66be33591f674b682986ac.zip |
Fix various Python-related bugs.
Diffstat (limited to 'source4/param/param_wrap.c')
-rw-r--r-- | source4/param/param_wrap.c | 19 |
1 files changed, 9 insertions, 10 deletions
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; } |