diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2016-12-10 13:55:43 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-03-10 07:31:10 +0100 |
commit | 31cef92cd3332ed674373b0de8526a4ab850d5d3 (patch) | |
tree | 2f2b44142d618d4b1637793eae6d1b1533e3709e /source4/param/pyparam_util.c | |
parent | 035e6dce4f4bf1363e7928797021feb0e6ec2fc2 (diff) | |
download | samba-31cef92cd3332ed674373b0de8526a4ab850d5d3.tar.gz |
python: samba.param: Port param module to Python 3
Port Python bindings of samba.param module to
Python3-compatible form.
Because native Python file objects are officially
no longer backed by FILE*, API of some _dump()
functions is changed. File argument is now
optional and contains only name of file. Stdout
is default if no file name is specified. Otherwise
opening and closing files is done on C layer
instead of Python.
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4/param/pyparam_util.c')
-rw-r--r-- | source4/param/pyparam_util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source4/param/pyparam_util.c b/source4/param/pyparam_util.c index 874d78363b7..512a8b1cdb7 100644 --- a/source4/param/pyparam_util.c +++ b/source4/param/pyparam_util.c @@ -18,6 +18,7 @@ */ #include <Python.h> +#include "py3compat.h" #include "includes.h" #include "param/param.h" #include "param/pyparam.h" @@ -33,14 +34,14 @@ _PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyOb PyTypeObject *lp_type; bool is_lpobj; - if (PyString_Check(py_obj)) { + if (PyStr_Check(py_obj)) { lp_ctx = loadparm_init_global(false); if (lp_ctx == NULL) { return NULL; } - if (!lpcfg_load(lp_ctx, PyString_AsString(py_obj))) { + if (!lpcfg_load(lp_ctx, PyStr_AsString(py_obj))) { PyErr_Format(PyExc_RuntimeError, "Unable to load %s", - PyString_AsString(py_obj)); + PyStr_AsString(py_obj)); return NULL; } return lp_ctx; |