[SCM] Samba Shared Repository - branch master updated

Noel Power npower at samba.org
Mon Jun 24 18:49:03 UTC 2019


The branch, master has been updated
       via  4f32983ea8a py3: Remove duplicated PyUnicode_Check() after the py3 compat macros were removed
       via  f32779b1982 py3: Remove PyStr_AsUTF8AndSize() compatability macro
       via  7566268f386 py3: Remove PyStr_AsUTF8() compatability macro
       via  f178daa854d py3: Remove PyStr_AsString() compatability macro
       via  d9d9463fd3c py3: Remove PyStr_FromFormatV() compatability macro
       via  75d87b29f11 py3: Remove PyStr_FromFormat() compatability macro
       via  3fa00d43504 py3: Remove PyStr_FromStringAndSize() compatability macro
       via  34f9a089d8d py3: Remove PyStr_FromString() compatability macro
       via  f498c819664 py3: Remove PyStr_Check() compatability macro
       via  559dd2d25a6 py3: Remove PyStr_Type() compatability macro
      from  5ae1767970d s4:ntp_signd: Use gnutls_error_to_ntstatus() in ntp_signd

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4f32983ea8a24466165c043a73cb47b4073da15f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Jun 15 23:14:49 2019 +1200

    py3: Remove duplicated PyUnicode_Check() after the py3 compat macros were removed
    
    This came about because in py2 we had to check for strings and unicode.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>
    
    Autobuild-User(master): Noel Power <npower at samba.org>
    Autobuild-Date(master): Mon Jun 24 18:48:53 UTC 2019 on sn-devel-184

commit f32779b198258da5b28cad6e810e4017c9f6dbc9
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:44:48 2019 +0200

    py3: Remove PyStr_AsUTF8AndSize() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 7566268f386b7014d3cfad802c4c46cd7b2b3956
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:21:15 2019 +0200

    py3: Remove PyStr_AsUTF8() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit f178daa854dc4ea9cb917d17cd4c8a876356e981
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:16:25 2019 +0200

    py3: Remove PyStr_AsString() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit d9d9463fd3c7eda14a3170e214d6a56c9efbbcec
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:13:03 2019 +0200

    py3: Remove PyStr_FromFormatV() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 75d87b29f11a1dacb37ccc1b10f8d034063ef5ba
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:08:55 2019 +0200

    py3: Remove PyStr_FromFormat() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 3fa00d435045e6faeb92f5379684f118b131c92c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 11:01:19 2019 +0200

    py3: Remove PyStr_FromStringAndSize() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 34f9a089d8d3a8971b2f7ee45f6d8e823a52a193
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 10:45:52 2019 +0200

    py3: Remove PyStr_FromString() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit f498c819664e9df658651d39f616f5b4d62b4750
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 10:39:11 2019 +0200

    py3: Remove PyStr_Check() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

commit 559dd2d25a644239902753e842b808bac1a0b439
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 7 10:27:34 2019 +0200

    py3: Remove PyStr_Type() compatability macro
    
    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 at samba.org>
    Reviewed-by: Noel Power <noel.power at suse.com>

-----------------------------------------------------------------------

Summary of changes:
 auth/credentials/pycredentials.c     |   2 +-
 lib/ldb/pyldb.c                      | 109 ++++++++++++++---------------------
 lib/ldb/pyldb_util.c                 |  12 +---
 lib/talloc/pytalloc.c                |  10 +---
 lib/tdb/pytdb.c                      |   9 +--
 lib/tevent/pytevent.c                |  13 +----
 libcli/nbt/pynbt.c                   |  32 +++++-----
 libgpo/pygpo.c                       |   6 +-
 pidl/lib/Parse/Pidl/Samba4/Python.pm |   6 +-
 python/modules.c                     |   2 +-
 python/py3compat.h                   |  13 +----
 python/pyglue.c                      |  12 ++--
 source3/passdb/py_passdb.c           |  98 +++++++++++++++----------------
 source4/auth/gensec/pygensec.c       |   4 +-
 source4/auth/pyauth.c                |   4 +-
 source4/dsdb/pydsdb.c                |  26 ++++-----
 source4/lib/policy/pypolicy.c        |   4 +-
 source4/lib/registry/pyregistry.c    |   6 +-
 source4/libnet/py_net.c              |   2 +-
 source4/librpc/ndr/py_lsa.c          |   8 +--
 source4/librpc/ndr/py_misc.c         |  10 ++--
 source4/librpc/ndr/py_security.c     |   8 +--
 source4/librpc/rpc/pyrpc.c           |   8 +--
 source4/librpc/rpc/pyrpc_util.c      |   2 +-
 source4/param/provision.c            |  44 +++++++-------
 source4/param/pyparam.c              |  40 ++++++-------
 source4/param/pyparam_util.c         |   6 +-
 27 files changed, 218 insertions(+), 278 deletions(-)


Changeset truncated at 500 lines:

diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c
index 966c625a10e..1aef16a0145 100644
--- a/auth/credentials/pycredentials.c
+++ b/auth/credentials/pycredentials.c
@@ -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)
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 940e43e3192..85bcd84bc14 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -85,13 +85,6 @@ static struct ldb_message_element *PyObject_AsMessageElement(
 static PyTypeObject PyLdbBytesType;
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_Check PyUnicode_Check
-#define PyStr_FromString PyUnicode_FromString
-#define PyStr_FromStringAndSize PyUnicode_FromStringAndSize
-#define PyStr_FromFormat PyUnicode_FromFormat
-#define PyStr_FromFormatV PyUnicode_FromFormatV
-#define PyStr_AsUTF8 PyUnicode_AsUTF8
-#define PyStr_AsUTF8AndSize PyUnicode_AsUTF8AndSize
 #define PyInt_FromLong PyLong_FromLong
 
 #define PYARG_STR_UNI "es"
@@ -106,26 +99,10 @@ static PyObject *PyLdbBytes_FromStringAndSize(const char *msg, int size)
 	return result;
 }
 #else
-#define PyStr_Check PyString_Check
-#define PyStr_FromString PyString_FromString
-#define PyStr_FromStringAndSize PyString_FromStringAndSize
-#define PyStr_FromFormat PyString_FromFormat
-#define PyStr_FromFormatV PyString_FromFormatV
-#define PyStr_AsUTF8 PyString_AsString
 #define PyLdbBytes_FromStringAndSize PyString_FromStringAndSize
 
 #define PYARG_STR_UNI "et"
 
-const char *PyStr_AsUTF8AndSize(PyObject *pystr, Py_ssize_t *sizeptr);
-const char *
-PyStr_AsUTF8AndSize(PyObject *pystr, Py_ssize_t *sizeptr)
-{
-	const char * ret = PyString_AsString(pystr);
-	if (ret == NULL)
-		return NULL;
-	*sizeptr = PyString_Size(pystr);
-	return ret;
-}
 #endif
 
 static PyObject *richcmp(int cmp_val, int op)
@@ -154,9 +131,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");
 	}
 }
 
@@ -195,7 +172,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,
@@ -330,7 +307,7 @@ static PyObject *PyObject_FromLdbValue(const struct ldb_val *val)
 
 static PyObject *PyStr_FromLdbValue(const struct ldb_val *val)
 {
-	return PyStr_FromStringAndSize((const char *)val->data, val->length);
+	return PyUnicode_FromStringAndSize((const char *)val->data, val->length);
 }
 
 /**
@@ -456,7 +433,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;
@@ -519,24 +496,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)
@@ -547,7 +524,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)
@@ -594,7 +571,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;
@@ -603,7 +580,7 @@ static PyObject *py_ldb_dn_repr(PyLdbDnObject *self)
 		Py_DECREF(str);
 		return NULL;
 	}
-	result = PyStr_FromFormat("Dn(%s)", PyStr_AsUTF8(repr));
+	result = PyUnicode_FromFormat("Dn(%s)", PyUnicode_AsUTF8(repr));
 	Py_DECREF(str);
 	Py_DECREF(repr);
 	return result;
@@ -728,7 +705,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)
@@ -786,7 +763,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,
@@ -996,7 +973,7 @@ static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *
 static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap)
 {
 	PyObject *fn = (PyObject *)context;
-	PyObject_CallFunction(fn, discard_const_p(char, "(i,O)"), level, PyStr_FromFormatV(fmt, ap));
+	PyObject_CallFunction(fn, discard_const_p(char, "(i,O)"), level, PyUnicode_FromFormatV(fmt, ap));
 }
 
 static PyObject *py_ldb_debug_func;
@@ -1098,7 +1075,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,
@@ -1157,12 +1134,12 @@ static const char **PyList_AsStrList(TALLOC_CTX *mem_ctx, PyObject *list,
 		const char *str = NULL;
 		Py_ssize_t size;
 		PyObject *item = PyList_GetItem(list, i);
-		if (!(PyStr_Check(item) || PyUnicode_Check(item))) {
+		if (!PyUnicode_Check(item)) {
 			PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
 			talloc_free(ret);
 			return NULL;
 		}
-		str = PyStr_AsUTF8AndSize(item, &size);
+		str = PyUnicode_AsUTF8AndSize(item, &size);
 		if (str == NULL) {
 			talloc_free(ret);
 			return NULL;
@@ -1395,7 +1372,7 @@ static struct ldb_message *PyDict_AsMessage(TALLOC_CTX *mem_ctx,
 	}
 
 	while (PyDict_Next(py_obj, &dict_pos, &key, &value)) {
-		const char *key_str = PyStr_AsUTF8(key);
+		const char *key_str = PyUnicode_AsUTF8(key);
 		if (ldb_attr_cmp(key_str, "dn") != 0) {
 			msg_el = PyObject_AsMessageElement(msg->elements, value,
 							   mod_flags, key_str);
@@ -1740,7 +1717,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);
 
@@ -2068,7 +2045,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);
@@ -2608,7 +2585,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>");
 }
 
 
@@ -2753,7 +2730,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 = {
@@ -2770,13 +2747,13 @@ static PyTypeObject PyLdbSearchIterator = {
 
 static PyObject *py_ldb_module_repr(PyLdbModuleObject *self)
 {
-	return PyStr_FromFormat("<ldb module '%s'>",
+	return PyUnicode_FromFormat("<ldb module '%s'>",
 		pyldb_Module_AsModule(self)->ops->name);
 }
 
 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,
@@ -3019,7 +2996,7 @@ static struct ldb_message_element *PyObject_AsMessageElement(
 			}
 			msg = _msg;
 		} else {
-			msg = PyStr_AsUTF8AndSize(set_obj, &size);
+			msg = PyUnicode_AsUTF8AndSize(set_obj, &size);
 			if (msg == NULL) {
 				talloc_free(me);
 				return NULL;
@@ -3044,7 +3021,7 @@ static struct ldb_message_element *PyObject_AsMessageElement(
 				}
 				msg = _msg;
 			} else if (PyUnicode_Check(obj)) {
-				msg = PyStr_AsUTF8AndSize(obj, &size);
+				msg = PyUnicode_AsUTF8AndSize(obj, &size);
 				if (msg == NULL) {
 					talloc_free(me);
 					return NULL;
@@ -3228,7 +3205,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 				result = PyBytes_AsStringAndSize(py_elements, &_msg, &size);
 				msg = _msg;
 			} else {
-				msg = PyStr_AsUTF8AndSize(py_elements, &size);
+				msg = PyUnicode_AsUTF8AndSize(py_elements, &size);
 				result = (msg == NULL) ? -1 : 0;
 			}
 			if (result != 0) {
@@ -3257,7 +3234,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 					result = PyBytes_AsStringAndSize(item, &_msg, &size);
 					msg = _msg;
 				} else if (PyUnicode_Check(item)) {
-					msg = PyStr_AsUTF8AndSize(item, &size);
+					msg = PyUnicode_AsUTF8AndSize(item, &size);
 					result = (msg == NULL) ? -1 : 0;
 				} else {
 					PyErr_Format(PyExc_TypeError, 
@@ -3305,17 +3282,17 @@ static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self)
 		PyObject *o = py_ldb_msg_element_find(self, i);
 		repr = PyObject_Repr(o);
 		if (element_str == NULL)
-			element_str = talloc_strdup(NULL, PyStr_AsUTF8(repr));
+			element_str = talloc_strdup(NULL, PyUnicode_AsUTF8(repr));
 		else
-			element_str = talloc_asprintf_append(element_str, ",%s", PyStr_AsUTF8(repr));
+			element_str = talloc_asprintf_append(element_str, ",%s", PyUnicode_AsUTF8(repr));
 		Py_DECREF(repr);
 	}
 
 	if (element_str != NULL) {
-		ret = PyStr_FromFormat("MessageElement([%s])", element_str);
+		ret = PyUnicode_FromFormat("MessageElement([%s])", element_str);
 		talloc_free(element_str);
 	} else {
-		ret = PyStr_FromString("MessageElement([])");
+		ret = PyUnicode_FromString("MessageElement([])");
 	}
 
 	return ret;
@@ -3326,7 +3303,7 @@ static PyObject *py_ldb_msg_element_str(PyLdbMessageElementObject *self)
 	struct ldb_message_element *el = pyldb_MessageElement_AsMessageElement(self);
 
 	if (el->num_values == 1)
-		return PyStr_FromStringAndSize((char *)el->values[0].data, el->values[0].length);
+		return PyUnicode_FromStringAndSize((char *)el->values[0].data, el->values[0].length);
 	else
 		Py_RETURN_NONE;
 }
@@ -3428,11 +3405,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;
@@ -3443,7 +3420,7 @@ static PyObject *py_ldb_msg_getitem_helper(PyLdbMessageObject *self, PyObject *p
 	struct ldb_message_element *el;
 	const char *name;
 	struct ldb_message *msg = pyldb_Message_AsMessage(self);
-	name = PyStr_AsUTF8(py_name);
+	name = PyUnicode_AsUTF8(py_name);
 	if (name == NULL) {
 		PyErr_SetNone(PyExc_TypeError);
 		return NULL;
@@ -3643,7 +3620,7 @@ static int py_ldb_msg_setitem(PyLdbMessageObject *self, PyObject *name, PyObject
 {
 	const char *attr_name;
 
-	attr_name = PyStr_AsUTF8(name);
+	attr_name = PyUnicode_AsUTF8(name);
 	if (attr_name == NULL) {
 		PyErr_SetNone(PyExc_TypeError);
 		return -1;
@@ -3787,7 +3764,7 @@ static PyObject *py_ldb_msg_repr(PyLdbMessageObject *self)
 		Py_DECREF(dict);
 		return NULL;
 	}
-	ret = PyStr_FromFormat("Message(%s)", PyStr_AsUTF8(repr));
+	ret = PyUnicode_FromFormat("Message(%s)", PyUnicode_AsUTF8(repr));
 	Py_DECREF(repr);
 	Py_DECREF(dict);
 	return ret;
@@ -3910,7 +3887,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"),
@@ -4170,7 +4147,7 @@ static PyObject *py_register_module(PyObject *module, PyObject *args)
 	}
 
 	tmp = PyObject_GetAttrString(input, discard_const_p(char, "name"));
-	ops->name = talloc_strdup(ops, PyStr_AsUTF8(tmp));
+	ops->name = talloc_strdup(ops, PyUnicode_AsUTF8(tmp));
 
 	Py_XDECREF(tmp);
 	Py_INCREF(input);
@@ -4207,7 +4184,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;
 }
@@ -4249,7 +4226,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;
 }
diff --git a/lib/ldb/pyldb_util.c b/lib/ldb/pyldb_util.c
index 46ee4034122..f8d0664f1e7 100644
--- a/lib/ldb/pyldb_util.c
+++ b/lib/ldb/pyldb_util.c
@@ -29,14 +29,6 @@
 
 static PyObject *ldb_module = NULL;
 
-#if PY_MAJOR_VERSION >= 3
-#define PyStr_Check PyUnicode_Check
-#define PyStr_AsUTF8 PyUnicode_AsUTF8
-#else
-#define PyStr_Check PyString_Check
-#define PyStr_AsUTF8 PyString_AsString
-#endif
-
 /**
  * Find out PyTypeObject in ldb module for a given typename
  */
@@ -70,8 +62,8 @@ bool pyldb_Object_AsDn(TALLOC_CTX *mem_ctx, PyObject *object,
 	struct ldb_dn *odn;
 	PyTypeObject *PyLdb_Dn_Type;
 
-	if (ldb_ctx != NULL && (PyStr_Check(object) || PyUnicode_Check(object))) {
-		odn = ldb_dn_new(mem_ctx, ldb_ctx, PyStr_AsUTF8(object));
+	if (ldb_ctx != NULL && (PyUnicode_Check(object))) {
+		odn = ldb_dn_new(mem_ctx, ldb_ctx, PyUnicode_AsUTF8(object));
 		*dn = odn;
 		return true;
 	}
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index b305b608f47..12c7325fcac 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -24,12 +24,6 @@
 
 static PyTypeObject TallocObject_Type;
 
-#if PY_MAJOR_VERSION >= 3
-#define PyStr_FromFormat PyUnicode_FromFormat
-#else
-#define PyStr_FromFormat PyString_FromFormat
-#endif
-
 /* print a talloc tree report for a talloc python object */
 static PyObject *pytalloc_report_full(PyObject *self, PyObject *args)
 {
@@ -87,7 +81,7 @@ static PyObject *pytalloc_default_repr(PyObject *obj)
 	pytalloc_Object *talloc_obj = (pytalloc_Object *)obj;
 	PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
 
-	return PyStr_FromFormat("<%s talloc object at %p>",
+	return PyUnicode_FromFormat("<%s talloc object at %p>",
 				type->tp_name, talloc_obj->ptr);
 }
 
@@ -167,7 +161,7 @@ static PyObject *pytalloc_base_default_repr(PyObject *obj)
 	pytalloc_BaseObject *talloc_obj = (pytalloc_BaseObject *)obj;
 	PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
 
-	return PyStr_FromFormat("<%s talloc based object at %p>",
+	return PyUnicode_FromFormat("<%s talloc based object at %p>",
 				type->tp_name, talloc_obj->ptr);
 }
 
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 87867478b57..74e80f95ec5 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -32,15 +32,10 @@
 #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
 
 /* discard signature of 'func' in favour of 'target_sig' */
@@ -654,9 +649,9 @@ 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>)");


-- 
Samba Shared Repository



More information about the samba-cvs mailing list