py3: Remove PyStr_FromString() compatability macro
authorAndrew Bartlett <abartlet@samba.org>
Fri, 7 Jun 2019 08:45:52 +0000 (10:45 +0200)
committerNoel Power <npower@samba.org>
Mon, 24 Jun 2019 17:24:27 +0000 (17:24 +0000)
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard
function names.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
23 files changed:
auth/credentials/pycredentials.c
lib/ldb/pyldb.c
lib/tdb/pytdb.c
lib/tevent/pytevent.c
libcli/nbt/pynbt.c
libgpo/pygpo.c
pidl/lib/Parse/Pidl/Samba4/Python.pm
python/modules.c
python/py3compat.h
python/pyglue.c
source3/passdb/py_passdb.c
source4/auth/gensec/pygensec.c
source4/dsdb/pydsdb.c
source4/lib/policy/pypolicy.c
source4/lib/registry/pyregistry.c
source4/libnet/py_net.c
source4/librpc/ndr/py_lsa.c
source4/librpc/ndr/py_misc.c
source4/librpc/ndr/py_security.c
source4/librpc/rpc/pyrpc.c
source4/librpc/rpc/pyrpc_util.c
source4/param/provision.c
source4/param/pyparam.c

index 966c625a10e210f35915c64200594db634da1e7d..1aef16a0145ff7b27fa59fef15d8db3c2e64f3e4 100644 (file)
@@ -41,7 +41,7 @@ static PyObject *PyString_FromStringOrNULL(const char *str)
 {
        if (str == NULL)
                Py_RETURN_NONE;
-       return PyStr_FromString(str);
+       return PyUnicode_FromString(str);
 }
 
 static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
index 7487753c12d49142f4bd95322e30f4ada4b254fb..6f43cca78ca5d6ad814025b1fdbdbbb737998cc3 100644 (file)
@@ -85,7 +85,6 @@ static struct ldb_message_element *PyObject_AsMessageElement(
 static PyTypeObject PyLdbBytesType;
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_FromString PyUnicode_FromString
 #define PyStr_FromStringAndSize PyUnicode_FromStringAndSize
 #define PyStr_FromFormat PyUnicode_FromFormat
 #define PyStr_FromFormatV PyUnicode_FromFormatV
@@ -105,7 +104,6 @@ static PyObject *PyLdbBytes_FromStringAndSize(const char *msg, int size)
        return result;
 }
 #else
-#define PyStr_FromString PyString_FromString
 #define PyStr_FromStringAndSize PyString_FromStringAndSize
 #define PyStr_FromFormat PyString_FromFormat
 #define PyStr_FromFormatV PyString_FromFormatV
@@ -152,9 +150,9 @@ static PyObject *py_ldb_control_str(PyLdbControlObject *self)
                        PyErr_NoMemory();
                        return NULL;
                }
-               return PyStr_FromString(control);
+               return PyUnicode_FromString(control);
        } else {
-               return PyStr_FromString("ldb control");
+               return PyUnicode_FromString("ldb control");
        }
 }
 
@@ -193,7 +191,7 @@ static PyObject *wrap_text(const char *type, PyObject *wrapped)
 static PyObject *py_ldb_control_get_oid(PyLdbControlObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(self->data->oid);
+       return PyUnicode_FromString(self->data->oid);
 }
 
 static PyObject *py_ldb_control_get_critical(PyLdbControlObject *self,
@@ -454,7 +452,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
        }
 
        for (i = 0;result->refs && result->refs[i]; i++) {
-               PyList_SetItem(referals, i, PyStr_FromString(result->refs[i]));
+               PyList_SetItem(referals, i, PyUnicode_FromString(result->refs[i]));
        }
        ret->referals = referals;
        return (PyObject *)ret;
@@ -517,24 +515,24 @@ static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self,
 static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(ldb_dn_get_casefold(self->dn));
+       return PyUnicode_FromString(ldb_dn_get_casefold(self->dn));
 }
 
 static PyObject *py_ldb_dn_get_linearized(PyLdbDnObject *self)
 {
-       return PyStr_FromString(ldb_dn_get_linearized(self->dn));
+       return PyUnicode_FromString(ldb_dn_get_linearized(self->dn));
 }
 
 static PyObject *py_ldb_dn_canonical_str(PyLdbDnObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(ldb_dn_canonical_string(self->dn, self->dn));
+       return PyUnicode_FromString(ldb_dn_canonical_string(self->dn, self->dn));
 }
 
 static PyObject *py_ldb_dn_canonical_ex_str(PyLdbDnObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(ldb_dn_canonical_ex_string(self->dn, self->dn));
+       return PyUnicode_FromString(ldb_dn_canonical_ex_string(self->dn, self->dn));
 }
 
 static PyObject *py_ldb_dn_extended_str(PyLdbDnObject *self, PyObject *args, PyObject *kwargs)
@@ -545,7 +543,7 @@ static PyObject *py_ldb_dn_extended_str(PyLdbDnObject *self, PyObject *args, PyO
                                         discard_const_p(char *, kwnames),
                                         &mode))
                return NULL;
-       return PyStr_FromString(ldb_dn_get_extended_linearized(self->dn, self->dn, mode));
+       return PyUnicode_FromString(ldb_dn_get_extended_linearized(self->dn, self->dn, mode));
 }
 
 static PyObject *py_ldb_dn_get_extended_component(PyLdbDnObject *self, PyObject *args)
@@ -592,7 +590,7 @@ static PyObject *py_ldb_dn_set_extended_component(PyLdbDnObject *self, PyObject
 
 static PyObject *py_ldb_dn_repr(PyLdbDnObject *self)
 {
-       PyObject *str = PyStr_FromString(ldb_dn_get_linearized(self->dn));
+       PyObject *str = PyUnicode_FromString(ldb_dn_get_linearized(self->dn));
        PyObject *repr, *result;
        if (str == NULL)
                return NULL;
@@ -726,7 +724,7 @@ static PyObject *py_ldb_dn_get_component_name(PyLdbDnObject *self, PyObject *arg
                Py_RETURN_NONE;
        }
 
-       return PyStr_FromString(name);
+       return PyUnicode_FromString(name);
 }
 
 static PyObject *py_ldb_dn_get_component_value(PyLdbDnObject *self, PyObject *args)
@@ -784,7 +782,7 @@ static PyObject *py_ldb_dn_get_rdn_name(PyLdbDnObject *self,
                Py_RETURN_NONE;
        }
 
-       return PyStr_FromString(name);
+       return PyUnicode_FromString(name);
 }
 
 static PyObject *py_ldb_dn_get_rdn_value(PyLdbDnObject *self,
@@ -1096,7 +1094,7 @@ static PyObject *py_ldb_setup_wellknown_attributes(PyLdbObject *self,
 
 static PyObject *py_ldb_repr(PyLdbObject *self)
 {
-       return PyStr_FromString("<ldb connection>");
+       return PyUnicode_FromString("<ldb connection>");
 }
 
 static PyObject *py_ldb_get_root_basedn(PyLdbObject *self,
@@ -1738,7 +1736,7 @@ static PyObject *py_ldb_write_ldif(PyLdbObject *self, PyObject *args)
                return NULL;
        }
 
-       ret = PyStr_FromString(string);
+       ret = PyUnicode_FromString(string);
 
        talloc_free(mem_ctx);
 
@@ -2066,7 +2064,7 @@ static int py_ldb_search_iterator_callback(struct ldb_request *req,
                return LDB_SUCCESS;
 
        case LDB_REPLY_REFERRAL:
-               reply->obj = PyStr_FromString(ares->referral);
+               reply->obj = PyUnicode_FromString(ares->referral);
                if (reply->obj == NULL) {
                        TALLOC_FREE(ares);
                        return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
@@ -2606,7 +2604,7 @@ static PySequenceMethods py_ldb_result_seq = {
 
 static PyObject *py_ldb_result_repr(PyLdbObject *self)
 {
-       return PyStr_FromString("<ldb result>");
+       return PyUnicode_FromString("<ldb result>");
 }
 
 
@@ -2751,7 +2749,7 @@ static PyMethodDef py_ldb_search_iterator_methods[] = {
 
 static PyObject *py_ldb_search_iterator_repr(PyLdbSearchIteratorObject *self)
 {
-       return PyStr_FromString("<ldb search iterator>");
+       return PyUnicode_FromString("<ldb search iterator>");
 }
 
 static PyTypeObject PyLdbSearchIterator = {
@@ -2774,7 +2772,7 @@ static PyObject *py_ldb_module_repr(PyLdbModuleObject *self)
 
 static PyObject *py_ldb_module_str(PyLdbModuleObject *self)
 {
-       return PyStr_FromString(pyldb_Module_AsModule(self)->ops->name);
+       return PyUnicode_FromString(pyldb_Module_AsModule(self)->ops->name);
 }
 
 static PyObject *py_ldb_module_start_transaction(PyLdbModuleObject *self,
@@ -3313,7 +3311,7 @@ static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self)
                ret = PyStr_FromFormat("MessageElement([%s])", element_str);
                talloc_free(element_str);
        } else {
-               ret = PyStr_FromString("MessageElement([])");
+               ret = PyUnicode_FromString("MessageElement([])");
        }
 
        return ret;
@@ -3426,11 +3424,11 @@ static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self,
        Py_ssize_t i, j = 0;
        PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
        if (msg->dn != NULL) {
-               PyList_SetItem(obj, j, PyStr_FromString("dn"));
+               PyList_SetItem(obj, j, PyUnicode_FromString("dn"));
                j++;
        }
        for (i = 0; i < msg->num_elements; i++) {
-               PyList_SetItem(obj, j, PyStr_FromString(msg->elements[i].name));
+               PyList_SetItem(obj, j, PyUnicode_FromString(msg->elements[i].name));
                j++;
        }
        return obj;
@@ -3908,7 +3906,7 @@ static int py_module_search(struct ldb_module *mod, struct ldb_request *req)
                for (len = 0; req->op.search.attrs[len]; len++);
                py_attrs = PyList_New(len);
                for (i = 0; i < len; i++)
-                       PyList_SetItem(py_attrs, i, PyStr_FromString(req->op.search.attrs[i]));
+                       PyList_SetItem(py_attrs, i, PyUnicode_FromString(req->op.search.attrs[i]));
        }
 
        py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "search"),
@@ -4205,7 +4203,7 @@ static PyObject *py_timestring(PyObject *module, PyObject *args)
        if (!PyArg_ParseTuple(args, "l", &t_val))
                return NULL;
        tresult = ldb_timestring(NULL, (time_t) t_val);
-       ret = PyStr_FromString(tresult);
+       ret = PyUnicode_FromString(tresult);
        talloc_free(tresult);
        return ret;
 }
@@ -4247,7 +4245,7 @@ static PyObject *py_binary_encode(PyObject *self, PyObject *args)
                PyErr_SetString(PyExc_TypeError, "unable to encode binary string");
                return NULL;
        }
-       ret = PyStr_FromString(encoded);
+       ret = PyUnicode_FromString(encoded);
        talloc_free(encoded);
        return ret;
 }
index 87867478b576ccb90e1a01421f8fbc82e1b25d13..ce671a92b9abb400b4250bfe7660746e499c69f9 100644 (file)
 #include <tdb.h>
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_FromString PyUnicode_FromString
 #define PyStr_FromFormat PyUnicode_FromFormat
 #define PyInt_FromLong PyLong_FromLong
 #define PyInt_Check PyLong_Check
 #define PyInt_AsLong PyLong_AsLong
 #define Py_TPFLAGS_HAVE_ITER 0
 #else
-#define PyStr_FromString PyString_FromString
 #define PyStr_FromFormat PyString_FromFormat
 #endif
 
@@ -654,7 +652,7 @@ static PyObject *tdb_object_repr(PyTdbObject *self)
 {
        PyErr_TDB_RAISE_IF_CLOSED(self);
        if (tdb_get_flags(self->ctx) & TDB_INTERNAL) {
-               return PyStr_FromString("Tdb(<internal>)");
+               return PyUnicode_FromString("Tdb(<internal>)");
        } else {
                return PyStr_FromFormat("Tdb('%s')", tdb_name(self->ctx));
        }
index 50252836b695b9e55a39f6fb9454ef9d0e9ef2ee..c39769f2f7931eb4a0ad007468be737c5a242b22 100644 (file)
 #include <tevent.h>
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_FromString PyUnicode_FromString
 #define PyStr_AsUTF8 PyUnicode_AsUTF8
 #define PyInt_FromLong PyLong_FromLong
 #else
-#define PyStr_FromString PyString_FromString
 #define PyStr_AsUTF8 PyString_AsString
 #endif
 
@@ -836,7 +834,7 @@ static PyObject *py_backend_list(PyObject *self,
                goto err;
        }
        for (i = 0; backends[i]; i++) {
-               string = PyStr_FromString(backends[i]);
+               string = PyUnicode_FromString(backends[i]);
                if (!string) {
                        goto err;
                }
index 4134c4344a6f0eabef1a53c931597aec3d0914dd..bcc98b78722e49d4b1ec3d2c9211e86a71ad1130 100644 (file)
@@ -190,7 +190,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
        ret = PyTuple_New(3);
        if (ret == NULL)
                return NULL;
-       PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
+       PyTuple_SetItem(ret, 0, PyUnicode_FromString(io.out.reply_from));
 
        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
        if (py_name == NULL)
@@ -205,7 +205,7 @@ static PyObject *py_nbt_name_query(PyObject *self, PyObject *args, PyObject *kwa
        }
 
        for (i = 0; i < io.out.num_addrs; i++) {
-               PyList_SetItem(reply_addrs, i, PyStr_FromString(io.out.reply_addrs[i]));
+               PyList_SetItem(reply_addrs, i, PyUnicode_FromString(io.out.reply_addrs[i]));
        }
 
        PyTuple_SetItem(ret, 2, reply_addrs);
@@ -248,7 +248,7 @@ static PyObject *py_nbt_name_status(PyObject *self, PyObject *args, PyObject *kw
        ret = PyTuple_New(3);
        if (ret == NULL)
                return NULL;
-       PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
+       PyTuple_SetItem(ret, 0, PyUnicode_FromString(io.out.reply_from));
 
        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
        if (py_name == NULL)
@@ -312,7 +312,7 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
        ret = PyTuple_New(4);
        if (ret == NULL)
                return NULL;
-       PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
+       PyTuple_SetItem(ret, 0, PyUnicode_FromString(io.out.reply_from));
 
        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
        if (py_name == NULL)
@@ -320,7 +320,7 @@ static PyObject *py_nbt_name_register(PyObject *self, PyObject *args, PyObject *
 
        PyTuple_SetItem(ret, 1, py_name);
 
-       PyTuple_SetItem(ret, 2, PyStr_FromString(io.out.reply_addr));
+       PyTuple_SetItem(ret, 2, PyUnicode_FromString(io.out.reply_addr));
 
        PyTuple_SetItem(ret, 3, PyInt_FromLong(io.out.rcode));
 
@@ -368,7 +368,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
        ret = PyTuple_New(3);
        if (ret == NULL)
                return NULL;
-       PyTuple_SetItem(ret, 0, PyStr_FromString(io.out.reply_from));
+       PyTuple_SetItem(ret, 0, PyUnicode_FromString(io.out.reply_from));
 
        py_name = PyObject_FromNBTName(node->socket, &io.out.name);
        if (py_name == NULL)
@@ -376,7 +376,7 @@ static PyObject *py_nbt_name_refresh(PyObject *self, PyObject *args, PyObject *k
 
        PyTuple_SetItem(ret, 1, py_name);
 
-       PyTuple_SetItem(ret, 2, PyStr_FromString(io.out.reply_addr));
+       PyTuple_SetItem(ret, 2, PyUnicode_FromString(io.out.reply_addr));
 
        PyTuple_SetItem(ret, 3, PyInt_FromLong(io.out.rcode));
 
index 35d35d69cbe72cf9680372e8bc1df43aeaa6bcaf..b1f788d3a00eb0a926e53f7891675b155fe06d5b 100644 (file)
@@ -39,7 +39,7 @@ static PyObject* GPO_get_##ATTR(PyObject *self, void *closure) \
                = pytalloc_get_ptr(self); \
        \
        if (gpo_ptr->ATTR) \
-               return PyStr_FromString(gpo_ptr->ATTR); \
+               return PyUnicode_FromString(gpo_ptr->ATTR); \
        else \
                return Py_None; \
 }
@@ -108,7 +108,7 @@ static PyObject *py_gpo_get_unix_path(PyObject *self, PyObject *args,
                goto out;
        }
 
-       ret = PyStr_FromString(unix_path);
+       ret = PyUnicode_FromString(unix_path);
 
 out:
        TALLOC_FREE(frame);
@@ -537,7 +537,7 @@ MODULE_INIT_FUNC(gpo)
        }
 
        if (PyModule_AddObject(m, "version",
-                          PyStr_FromString(SAMBA_VERSION_STRING)) ) {
+                          PyUnicode_FromString(SAMBA_VERSION_STRING)) ) {
                goto err;
        }
 
index 322aa6cc33e2de2a852170982000b4add4148759..e50c9378862c1f83084c69bf1d3c4773fdafb7dd 100644 (file)
@@ -367,7 +367,7 @@ sub PythonStruct($$$$$$)
                $self->pidl("char *retstr;");
                $self->pidl("");
                $self->pidl("retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
-               $self->pidl("ret = PyStr_FromString(retstr);");
+               $self->pidl("ret = PyUnicode_FromString(retstr);");
                $self->pidl("talloc_free(retstr);");
                $self->pidl("");
                $self->pidl("return ret;");
@@ -809,7 +809,7 @@ sub PythonFunctionStruct($$$$)
        $self->pidl("call = &ndr_table_$iface\.calls[$fn->{OPNUM}];");
        $self->pidl("");
        $self->pidl("retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);");
-       $self->pidl("ret = PyStr_FromString(retstr);");
+       $self->pidl("ret = PyUnicode_FromString(retstr);");
        $self->pidl("TALLOC_FREE(retstr);");
        $self->pidl("");
        $self->pidl("return ret;");
@@ -2407,7 +2407,7 @@ static inline long long ndr_sizeof2intmax(size_t var_size)
                if ($cvar =~ /^[0-9]+$/ or $cvar =~ /^0x[0-9a-fA-F]+$/) {
                        $py_obj = "PyLong_FromUnsignedLongLong($cvar)";
                } elsif ($cvar =~ /^".*"$/) {
-                       $py_obj = "PyStr_FromString($cvar)";
+                       $py_obj = "PyUnicode_FromString($cvar)";
                } else {
                        $py_obj = $self->ConvertObjectToPythonData("NULL", expandAlias($ctype), $cvar, undef);
                }
index ae91b0939aedd782d7837abcde17af8a1c2e3e7a..d8b330b6b287e8b56e44e4c4d213d85157f8b4a5 100644 (file)
@@ -26,7 +26,7 @@
 static bool PySys_PathPrepend(PyObject *list, const char *path)
 {
        bool ok;
-       PyObject *py_path = PyStr_FromString(path);
+       PyObject *py_path = PyUnicode_FromString(path);
        if (py_path == NULL) {
                return false;
        }
index 9a98339d9160d20ca5a2abb688e76a2e523b20f7..bb35673c1a1ca6754946c9cc7ef557d916a9621c 100644 (file)
@@ -54,7 +54,6 @@
 
 /* Strings */
 
-#define PyStr_FromString PyUnicode_FromString
 #define PyStr_FromStringAndSize PyUnicode_FromStringAndSize
 #define PyStr_FromFormat PyUnicode_FromFormat
 #define PyStr_FromFormatV PyUnicode_FromFormatV
index b998aff223e06f231fde34c76392ad5d0107c72d..83b968bad8c80363cebe58bf59fc8c67b270cec2 100644 (file)
@@ -40,7 +40,7 @@ static PyObject *py_generate_random_str(PyObject *self, PyObject *args)
                return NULL;
 
        retstr = generate_random_str(NULL, len);
-       ret = PyStr_FromString(retstr);
+       ret = PyUnicode_FromString(retstr);
        talloc_free(retstr);
        return ret;
 }
@@ -57,7 +57,7 @@ static PyObject *py_generate_random_password(PyObject *self, PyObject *args)
        if (retstr == NULL) {
                return NULL;
        }
-       ret = PyStr_FromString(retstr);
+       ret = PyUnicode_FromString(retstr);
        talloc_free(retstr);
        return ret;
 }
@@ -150,7 +150,7 @@ static PyObject *py_nttime2string(PyObject *self, PyObject *args)
        }
 
        string = nt_time_string(tmp_ctx, nt);
-       ret =  PyStr_FromString(string);
+       ret =  PyUnicode_FromString(string);
 
        talloc_free(tmp_ctx);
 
@@ -272,7 +272,7 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
                const char *ip = iface_list_n_ip(ifaces, i);
 
                if (all_interfaces) {
-                       PyList_SetItem(pylist, ifcount, PyStr_FromString(ip));
+                       PyList_SetItem(pylist, ifcount, PyUnicode_FromString(ip));
                        ifcount++;
                        continue;
                }
@@ -293,7 +293,7 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
                        continue;
                }
 
-               PyList_SetItem(pylist, ifcount, PyStr_FromString(ip));
+               PyList_SetItem(pylist, ifcount, PyUnicode_FromString(ip));
                ifcount++;
        }
        talloc_free(tmp_ctx);
@@ -411,7 +411,7 @@ MODULE_INIT_FUNC(_glue)
                return NULL;
 
        PyModule_AddObject(m, "version",
-                                          PyStr_FromString(SAMBA_VERSION_STRING));
+                                          PyUnicode_FromString(SAMBA_VERSION_STRING));
        PyExc_NTSTATUSError = PyErr_NewException(discard_const_p(char, "samba.NTSTATUSError"), PyExc_RuntimeError, NULL);
        if (PyExc_NTSTATUSError != NULL) {
                Py_INCREF(PyExc_NTSTATUSError);
index aa5458211e1f9e93f86261f11e0edf589791e9ba..0c0f1be50557af720a070db93d1012cc23c9391d 100644 (file)
@@ -239,7 +239,7 @@ static PyObject *py_samu_get_username(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_username = PyStr_FromString(username);
+       py_username = PyUnicode_FromString(username);
        talloc_free(frame);
        return py_username;
 }
@@ -270,7 +270,7 @@ static PyObject *py_samu_get_domain(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_domain = PyStr_FromString(domain);
+       py_domain = PyUnicode_FromString(domain);
        talloc_free(frame);
        return py_domain;
 }
@@ -301,7 +301,7 @@ static PyObject *py_samu_get_nt_username(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_nt_username = PyStr_FromString(nt_username);
+       py_nt_username = PyUnicode_FromString(nt_username);
        talloc_free(frame);
        return py_nt_username;
 }
@@ -332,7 +332,7 @@ static PyObject *py_samu_get_full_name(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_full_name = PyStr_FromString(full_name);
+       py_full_name = PyUnicode_FromString(full_name);
        talloc_free(frame);
        return py_full_name;
 }
@@ -363,7 +363,7 @@ static PyObject *py_samu_get_home_dir(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_home_dir = PyStr_FromString(home_dir);
+       py_home_dir = PyUnicode_FromString(home_dir);
        talloc_free(frame);
        return py_home_dir;
 }
@@ -394,7 +394,7 @@ static PyObject *py_samu_get_dir_drive(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_dir_drive = PyStr_FromString(dir_drive);
+       py_dir_drive = PyUnicode_FromString(dir_drive);
        talloc_free(frame);
        return py_dir_drive;
 }
@@ -425,7 +425,7 @@ static PyObject *py_samu_get_logon_script(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_logon_script = PyStr_FromString(logon_script);
+       py_logon_script = PyUnicode_FromString(logon_script);
        talloc_free(frame);
        return py_logon_script;
 }
@@ -456,7 +456,7 @@ static PyObject *py_samu_get_profile_path(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_profile_path = PyStr_FromString(profile_path);
+       py_profile_path = PyUnicode_FromString(profile_path);
        talloc_free(frame);
        return py_profile_path;
 }
@@ -487,7 +487,7 @@ static PyObject *py_samu_get_acct_desc(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_acct_desc = PyStr_FromString(acct_desc);
+       py_acct_desc = PyUnicode_FromString(acct_desc);
        talloc_free(frame);
        return py_acct_desc;
 }
@@ -518,7 +518,7 @@ static PyObject *py_samu_get_workstations(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_workstations = PyStr_FromString(workstations);
+       py_workstations = PyUnicode_FromString(workstations);
        talloc_free(frame);
        return py_workstations;
 }
@@ -549,7 +549,7 @@ static PyObject *py_samu_get_comment(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_comment = PyStr_FromString(comment);
+       py_comment = PyUnicode_FromString(comment);
        talloc_free(frame);
        return py_comment;
 }
@@ -580,7 +580,7 @@ static PyObject *py_samu_get_munged_dial(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_munged_dial = PyStr_FromString(munged_dial);
+       py_munged_dial = PyUnicode_FromString(munged_dial);
        talloc_free(frame);
        return py_munged_dial;
 }
@@ -795,7 +795,7 @@ static PyObject *py_samu_get_plaintext_passwd(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
-       py_plaintext_pw = PyStr_FromString(plaintext_pw);
+       py_plaintext_pw = PyUnicode_FromString(plaintext_pw);
        talloc_free(frame);
        return py_plaintext_pw;
 }
@@ -1346,7 +1346,7 @@ static PyObject *py_groupmap_get_nt_name(PyObject *obj, void *closure)
                py_nt_name = Py_None;
                Py_INCREF(py_nt_name);
        } else {
-               py_nt_name = PyStr_FromString(group_map->nt_name);
+               py_nt_name = PyUnicode_FromString(group_map->nt_name);
        }
        talloc_free(frame);
        return py_nt_name;
@@ -1376,7 +1376,7 @@ static PyObject *py_groupmap_get_comment(PyObject *obj, void *closure)
                py_comment = Py_None;
                Py_INCREF(py_comment);
        } else {
-               py_comment = PyStr_FromString(group_map->comment);
+               py_comment = PyUnicode_FromString(group_map->comment);
        }
        talloc_free(frame);
        return py_comment;
@@ -3823,7 +3823,7 @@ static PyObject *py_passdb_backends(PyObject *self, PyObject *unused)
 
        while(entry) {
                int res = 0;
-               PyObject *entry_name = PyStr_FromString(entry->name);
+               PyObject *entry_name = PyUnicode_FromString(entry->name);
                if (entry_name) {
                        res = PyList_Append(py_blist, entry_name);
                } else {
index c62d2be081ef8daf223b13934474623c401e9565..8996ac2bc33b0a82febd2ad30d2f2aaa99d84a65 100644 (file)
@@ -45,7 +45,7 @@ static PyObject *py_get_name_by_authtype(PyObject *self, PyObject *args)
        if (name == NULL)
                Py_RETURN_NONE;
 
-       return PyStr_FromString(name);
+       return PyUnicode_FromString(name);
 }
 
 static struct gensec_settings *settings_from_object(TALLOC_CTX *mem_ctx, PyObject *object)
index 255ec656330f409202863bb72a2e0edef127be28..11b19c6499c0f78c38d1386fc10913f0958dc06c 100644 (file)
@@ -97,7 +97,7 @@ static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       result = PyStr_FromString(site);
+       result = PyUnicode_FromString(site);
        talloc_free(mem_ctx);
        return result;
 }
@@ -123,7 +123,7 @@ static PyObject *py_dsdb_convert_schema_to_openldap(PyObject *self,
                return NULL;
        } 
 
-       ret = PyStr_FromString(retstr);
+       ret = PyUnicode_FromString(retstr);
        talloc_free(retstr);
        return ret;
 }
@@ -208,7 +208,7 @@ static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args)
                return NULL;
        }
 
-       ret = PyStr_FromString(dom_sid_str_buf(sid, &buf));
+       ret = PyUnicode_FromString(dom_sid_str_buf(sid, &buf));
        return ret;
 }
 
@@ -237,7 +237,7 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
                PyErr_NoMemory();
                return NULL;
        }
-       result = PyStr_FromString(retstr);
+       result = PyUnicode_FromString(retstr);
        talloc_free(retstr);
        return result;
 }
@@ -279,7 +279,7 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       ret = PyStr_FromString(oid);
+       ret = PyUnicode_FromString(oid);
 
        talloc_free(mem_ctx);
 
@@ -434,7 +434,7 @@ static PyObject *py_dsdb_get_backlink_from_lDAPDisplayName(PyObject *self, PyObj
                Py_RETURN_NONE;
        }
 
-       return PyStr_FromString(target_attr->lDAPDisplayName);
+       return PyUnicode_FromString(target_attr->lDAPDisplayName);
 }
 
 
@@ -464,7 +464,7 @@ static PyObject *py_dsdb_get_lDAPDisplayName_by_attid(PyObject *self, PyObject *
                return NULL;
        }
 
-       return PyStr_FromString(a->lDAPDisplayName);
+       return PyUnicode_FromString(a->lDAPDisplayName);
 }
 
 
@@ -497,7 +497,7 @@ static PyObject *py_dsdb_get_syntax_oid_from_lDAPDisplayName(PyObject *self, PyO
                return NULL;
        }
 
-       return PyStr_FromString(attribute->syntax->ldap_oid);
+       return PyUnicode_FromString(attribute->syntax->ldap_oid);
 }
 
 /*
@@ -821,7 +821,7 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args)
                PyErr_NoMemory();
                return NULL;
        }
-       result = PyStr_FromString(retstr);
+       result = PyUnicode_FromString(retstr);
        talloc_free(retstr);
        return result;
 }
@@ -1656,7 +1656,7 @@ MODULE_INIT_FUNC(dsdb)
        ADD_DSDB_FLAG(GPO_INHERIT);
        ADD_DSDB_FLAG(GPO_BLOCK_INHERITANCE);
 
-#define ADD_DSDB_STRING(val)  PyModule_AddObject(m, #val, PyStr_FromString(val))
+#define ADD_DSDB_STRING(val)  PyModule_AddObject(m, #val, PyUnicode_FromString(val))
 
        ADD_DSDB_STRING(DSDB_SYNTAX_BINARY_DN);
        ADD_DSDB_STRING(DSDB_SYNTAX_STRING_DN);
index 0e8c89fd58b5a7db87315e50031e2a2c0ef7e8e7..038fa0428c37a82eb6e1bee8411f9b598ee85e01 100644 (file)
@@ -53,7 +53,7 @@ static PyObject *py_get_gpo_flags(PyObject *self, PyObject *args)
        py_ret = PyList_New(0);
        for (i = 0; ret[i]; i++) {
                int res = 0;
-               PyObject *item = PyStr_FromString(ret[i]);
+               PyObject *item = PyUnicode_FromString(ret[i]);
                if (item == NULL) {
                        talloc_free(mem_ctx);
                        Py_DECREF(py_ret);
@@ -102,7 +102,7 @@ static PyObject *py_get_gplink_options(PyObject *self, PyObject *args)
        py_ret = PyList_New(0);
        for (i = 0; ret[i]; i++) {
                int res = 0;
-               PyObject *item = PyStr_FromString(ret[i]);
+               PyObject *item = PyUnicode_FromString(ret[i]);
                if (item == NULL) {
                        talloc_free(mem_ctx);
                        Py_DECREF(py_ret);
index 5da804fb048de17603665d251ab0edc9b308400b..daa9ba903c25171ee2c94465841b4998698c976f 100644 (file)
@@ -417,7 +417,7 @@ static PyObject *py_str_regtype(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "i", &regtype))
                return NULL;
        
-       return PyStr_FromString(str_regtype(regtype));
+       return PyUnicode_FromString(str_regtype(regtype));
 }
 
 static PyObject *py_get_predef_name(PyObject *self, PyObject *args)
@@ -431,7 +431,7 @@ static PyObject *py_get_predef_name(PyObject *self, PyObject *args)
        str = reg_get_predef_name(hkey);
        if (str == NULL)
                Py_RETURN_NONE;
-       return PyStr_FromString(str);
+       return PyUnicode_FromString(str);
 }
 
 static PyMethodDef py_registry_methods[] = {
index 5beeeab1fa8e98720cf804719430ded8d4e20a90..25a25b0cfd11521ec5671b31af65fd9a0816564a 100644 (file)
@@ -325,7 +325,7 @@ static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwar
        tm = localtime(&r.generic.out.time);
        strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);
        
-       ret = PyStr_FromString(timestr);
+       ret = PyUnicode_FromString(timestr);
 
        talloc_free(mem_ctx);
 
index f9857a5695720c0143e1919d4b8c6ebfe28f6d7c..fe01de36fea558b63bbafa70e743f47b88c29976 100644 (file)
@@ -26,9 +26,9 @@ static PyObject *py_lsa_String_str(PyObject *py_self)
        PyObject *ret = NULL;
        if (self->string == NULL) {
                const char *empty = "";
-               ret = PyStr_FromString(empty);
+               ret = PyUnicode_FromString(empty);
        } else {
-               ret = PyStr_FromString(self->string);
+               ret = PyUnicode_FromString(self->string);
        }
        return ret;
 }
@@ -39,7 +39,7 @@ static PyObject *py_lsa_String_repr(PyObject *py_self)
        PyObject *ret = NULL;
        if (self->string == NULL) {
                const char *empty = "lsaString(None)";
-               ret = PyStr_FromString(empty);
+               ret = PyUnicode_FromString(empty);
        } else {
                ret = PyStr_FromFormat("lsaString('%s')", self->string);
        }
index 187fdb784cf9651a5a15d120aa27170d9ba9a427..5e6af484f26a5fd84c88841a9dd1bdb2cda07908 100644 (file)
@@ -69,7 +69,7 @@ static PyObject *py_GUID_str(PyObject *py_self)
 {
        struct GUID *self = pytalloc_get_ptr(py_self);
        char *str = GUID_string(NULL, self);
-       PyObject *ret = PyStr_FromString(str);
+       PyObject *ret = PyUnicode_FromString(str);
        talloc_free(str);
        return ret;
 }
index ecac43bb258e6c79b13cb2b237e86c5975a819da..b9dd29310e6381905605541c4c946fa5daa6c1bf 100644 (file)
@@ -116,7 +116,7 @@ static PyObject *py_dom_sid_str(PyObject *py_self)
 {
        struct dom_sid *self = pytalloc_get_ptr(py_self);
        struct dom_sid_buf buf;
-       PyObject *ret = PyStr_FromString(dom_sid_str_buf(self, &buf));
+       PyObject *ret = PyUnicode_FromString(dom_sid_str_buf(self, &buf));
        return ret;
 }
 
@@ -285,7 +285,7 @@ static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *args)
 
        text = sddl_encode(NULL, desc, sid);
 
-       ret = PyStr_FromString(text);
+       ret = PyUnicode_FromString(text);
 
        talloc_free(text);
 
@@ -438,7 +438,7 @@ static PyObject *py_privilege_name(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "i", &priv))
                return NULL;
 
-       return PyStr_FromString(sec_privilege_name(priv));
+       return PyUnicode_FromString(sec_privilege_name(priv));
 }
 
 static PyObject *py_privilege_id(PyObject *self, PyObject *args)
index 90c890d2a0c1965523b33a7f84cf6abc8e334e70..067dadf54a202ea4750539c8ea3edd62f8090ded 100644 (file)
@@ -95,7 +95,7 @@ static PyObject *py_iface_server_name(PyObject *obj, void *closure)
        if (server_name == NULL)
                Py_RETURN_NONE;
 
-       return PyStr_FromString(server_name);
+       return PyUnicode_FromString(server_name);
 }
 
 static PyObject *py_ndr_syntax_id(struct ndr_syntax_id *syntax_id)
index e6227eaa60496cc696e421c6432bd86c319cd4bc..0d6a16518f1f375bcc13d5f3a18087274ab8b4e7 100644 (file)
@@ -416,7 +416,7 @@ PyObject *PyString_FromStringOrNULL(const char *str)
        if (str == NULL) {
                Py_RETURN_NONE;
        }
-       return PyStr_FromString(str);
+       return PyUnicode_FromString(str);
 }
 
 PyObject *pyrpc_import_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,
index 85671f80b87586fd60cd0cecc0e844b54c8749e8..177fb93f18c0fbfcd3f740b24422aef7df69b27b 100644 (file)
@@ -45,7 +45,7 @@ static bool dict_insert(PyObject* dict,
 
 static PyObject *provision_module(void)
 {
-       PyObject *name = PyStr_FromString("samba.provision");
+       PyObject *name = PyUnicode_FromString("samba.provision");
        PyObject *mod = NULL;
        if (name == NULL)
                return NULL;
@@ -56,7 +56,7 @@ static PyObject *provision_module(void)
 
 static PyObject *schema_module(void)
 {
-       PyObject *name = PyStr_FromString("samba.schema");
+       PyObject *name = PyUnicode_FromString("samba.schema");
        PyObject *mod = NULL;
        if (name == NULL)
                return NULL;
@@ -67,7 +67,7 @@ static PyObject *schema_module(void)
 
 static PyObject *ldb_module(void)
 {
-       PyObject *name = PyStr_FromString("ldb");
+       PyObject *name = PyUnicode_FromString("ldb");
        PyObject *mod = NULL;
        if (name == NULL)
                return NULL;
@@ -152,7 +152,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        configfile = lpcfg_configfile(lp_ctx);
        if (configfile != NULL) {
                if (!dict_insert(parameters, "smbconf",
-                                PyStr_FromString(configfile))) {
+                                PyUnicode_FromString(configfile))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -160,40 +160,40 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 
        if (!dict_insert(parameters,
                         "rootdn",
-                        PyStr_FromString(settings->root_dn_str))) {
+                        PyUnicode_FromString(settings->root_dn_str))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (settings->targetdir != NULL) {
                if (!dict_insert(parameters,
                                 "targetdir",
-                                PyStr_FromString(settings->targetdir))) {
+                                PyUnicode_FromString(settings->targetdir))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
        }
        if (!dict_insert(parameters,
                         "hostname",
-                        PyStr_FromString(settings->netbios_name))) {
+                        PyUnicode_FromString(settings->netbios_name))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (!dict_insert(parameters,
                         "domain",
-                        PyStr_FromString(settings->domain))) {
+                        PyUnicode_FromString(settings->domain))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (!dict_insert(parameters,
                         "realm",
-                        PyStr_FromString(settings->realm))) {
+                        PyUnicode_FromString(settings->realm))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (settings->root_dn_str) {
                if (!dict_insert(parameters,
                                 "rootdn",
-                                PyStr_FromString(settings->root_dn_str))) {
+                                PyUnicode_FromString(settings->root_dn_str))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -202,7 +202,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        if (settings->domain_dn_str) {
                if (!dict_insert(parameters,
                                 "domaindn",
-                                PyStr_FromString(settings->domain_dn_str))) {
+                                PyUnicode_FromString(settings->domain_dn_str))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -211,7 +211,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        if (settings->schema_dn_str) {
                if (!dict_insert(parameters,
                                 "schemadn",
-                                PyStr_FromString(settings->schema_dn_str))) {
+                                PyUnicode_FromString(settings->schema_dn_str))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -219,7 +219,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        if (settings->config_dn_str) {
                if (!dict_insert(parameters,
                                 "configdn",
-                                PyStr_FromString(settings->config_dn_str))) {
+                                PyUnicode_FromString(settings->config_dn_str))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -227,7 +227,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        if (settings->server_dn_str) {
                if (!dict_insert(parameters,
                                 "serverdn",
-                                PyStr_FromString(settings->server_dn_str))) {
+                                PyUnicode_FromString(settings->server_dn_str))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -235,7 +235,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
        if (settings->site_name) {
                if (!dict_insert(parameters,
                                 "sitename",
-                                 PyStr_FromString(settings->site_name))) {
+                                 PyUnicode_FromString(settings->site_name))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
@@ -243,7 +243,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
 
        if (!dict_insert(parameters,
                         "machinepass",
-                        PyStr_FromString(settings->machine_password))){
+                        PyUnicode_FromString(settings->machine_password))){
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
@@ -403,27 +403,27 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
        }
        if (!dict_insert(parameters,
                         "domain",
-                        PyStr_FromString(settings->domain_name))) {
+                        PyUnicode_FromString(settings->domain_name))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (settings->realm != NULL) {
                if (!dict_insert(parameters,
                                 "realm",
-                                PyStr_FromString(settings->realm))) {
+                                PyUnicode_FromString(settings->realm))) {
                        status = NT_STATUS_UNSUCCESSFUL;
                        goto out;
                }
        }
        if (!dict_insert(parameters,
                         "machinepass",
-                        PyStr_FromString(settings->machine_password))) {
+                        PyUnicode_FromString(settings->machine_password))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
        if (!dict_insert(parameters,
                         "netbiosname",
-                        PyStr_FromString(settings->netbios_name))) {
+                        PyUnicode_FromString(settings->netbios_name))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }
@@ -527,7 +527,7 @@ struct ldb_context *provision_get_schema(TALLOC_CTX *mem_ctx,
        if (schema_dn) {
                if (!dict_insert(parameters,
                                 "schemadn",
-                                PyStr_FromString(schema_dn))) {
+                                PyUnicode_FromString(schema_dn))) {
                        return NULL;
                }
        }
index df0879a3c714d30e2767fb5155f3c452bfc3ca07..cf7423ddec3f769548d3871393a9270181690ae2 100644 (file)
@@ -63,7 +63,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
                        if (value == NULL) {
                        return NULL;
                        }
-                       return PyStr_FromString(value);
+                       return PyUnicode_FromString(value);
                }
 
                parm = lpcfg_parm_struct(lp_ctx, param_name);
@@ -83,7 +83,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
                value = lpcfg_get_parametric(lp_ctx, NULL, type, option);
                if (value == NULL)
                        return NULL;
-               return PyStr_FromString(value);
+               return PyUnicode_FromString(value);
        } else {
                /* its a global parameter */
                parm = lpcfg_parm_struct(lp_ctx, param_name);
@@ -103,7 +103,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
        return PyStr_FromFormat("%c", *(char *)parm_ptr);
     case P_STRING:
     case P_USTRING:
-       return PyStr_FromString(*(char **)parm_ptr);
+       return PyUnicode_FromString(*(char **)parm_ptr);
     case P_BOOL:
        return PyBool_FromLong(*(bool *)parm_ptr);
     case P_BOOLREV:
@@ -115,7 +115,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
     case P_ENUM:
        for (i=0; parm->enum_list[i].name; i++) {
            if (*(int *)parm_ptr == parm->enum_list[i].value) {
-               return PyStr_FromString(parm->enum_list[i].name);
+               return PyUnicode_FromString(parm->enum_list[i].name);
            }
        }
        return NULL;
@@ -133,7 +133,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
            pylist = PyList_New(str_list_length(strlist));
            for (j = 0; strlist[j]; j++) 
                PyList_SetItem(pylist, j, 
-                              PyStr_FromString(strlist[j]));
+                              PyUnicode_FromString(strlist[j]));
            return pylist;
        }
     }
@@ -225,7 +225,7 @@ static PyObject *py_lp_ctx_private_path(PyObject *self, PyObject *args)
                return NULL;
 
        path = lpcfg_private_path(NULL, PyLoadparmContext_AsLoadparmContext(self), name);
-       ret = PyStr_FromString(path);
+       ret = PyUnicode_FromString(path);
        talloc_free(path);
 
        return ret;
@@ -240,7 +240,7 @@ static PyObject *py_lp_ctx_services(PyObject *self, PyObject *unused)
        for (i = 0; i < lpcfg_numservices(lp_ctx); i++) {
                struct loadparm_service *service = lpcfg_servicebynum(lp_ctx, i);
                if (service != NULL) {
-                       PyList_SetItem(ret, i, PyStr_FromString(lpcfg_servicename(service)));
+                       PyList_SetItem(ret, i, PyUnicode_FromString(lpcfg_servicename(service)));
                }
        }
        return ret;
@@ -255,7 +255,7 @@ static PyObject *py_lp_ctx_server_role(PyObject *self, PyObject *unused)
        role = lpcfg_server_role(lp_ctx);
        role_str = server_role_str(role);
 
-       return PyStr_FromString(role_str);
+       return PyUnicode_FromString(role_str);
 }
 
 static PyObject *py_lp_dump(PyObject *self, PyObject *args)
@@ -375,7 +375,7 @@ static PyObject *py_cache_path(PyObject *self, PyObject *args)
                             "Unable to access cache %s", name);
                return NULL;
        }
-       ret = PyStr_FromString(path);
+       ret = PyUnicode_FromString(path);
        talloc_free(path);
 
        return ret;
@@ -399,7 +399,7 @@ static PyObject *py_state_path(PyObject *self, PyObject *args)
                             "Unable to access cache %s", name);
                return NULL;
        }
-       ret = PyStr_FromString(path);
+       ret = PyUnicode_FromString(path);
        talloc_free(path);
 
        return ret;
@@ -460,7 +460,7 @@ static PyObject *py_lp_ctx_config_file(PyObject *self, void *closure)
        if (configfile == NULL)
                Py_RETURN_NONE;
        else
-               return PyStr_FromString(configfile);
+               return PyUnicode_FromString(configfile);
 }
 
 static PyGetSetDef py_lp_ctx_getset[] = {
@@ -616,27 +616,27 @@ PyTypeObject PyLoadparmService = {
 
 static PyObject *py_default_path(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(lp_default_path());
+       return PyUnicode_FromString(lp_default_path());
 }
 
 static PyObject *py_setup_dir(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(dyn_SETUPDIR);
+       return PyUnicode_FromString(dyn_SETUPDIR);
 }
 
 static PyObject *py_modules_dir(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(dyn_MODULESDIR);
+       return PyUnicode_FromString(dyn_MODULESDIR);
 }
 
 static PyObject *py_bin_dir(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(dyn_BINDIR);
+       return PyUnicode_FromString(dyn_BINDIR);
 }
 
 static PyObject *py_sbin_dir(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
-       return PyStr_FromString(dyn_SBINDIR);
+       return PyUnicode_FromString(dyn_SBINDIR);
 }
 
 static PyMethodDef pyparam_methods[] = {