py3: Remove PyStr_FromFormat() compatability macro
authorAndrew Bartlett <abartlet@samba.org>
Fri, 7 Jun 2019 09:08:55 +0000 (11:08 +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>
lib/ldb/pyldb.c
lib/talloc/pytalloc.c
lib/tdb/pytdb.c
python/py3compat.h
source4/librpc/ndr/py_lsa.c
source4/librpc/ndr/py_misc.c
source4/librpc/ndr/py_security.c
source4/param/pyparam.c

index 958c3afab579b3ed5a3ccb42b019d3d80ded16b5..456be0b79f6882265c7f0e60fbbcb110f1ea6b3d 100644 (file)
@@ -85,7 +85,6 @@ static struct ldb_message_element *PyObject_AsMessageElement(
 static PyTypeObject PyLdbBytesType;
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_FromFormat PyUnicode_FromFormat
 #define PyStr_FromFormatV PyUnicode_FromFormatV
 #define PyStr_AsUTF8 PyUnicode_AsUTF8
 #define PyStr_AsUTF8AndSize PyUnicode_AsUTF8AndSize
@@ -103,7 +102,6 @@ static PyObject *PyLdbBytes_FromStringAndSize(const char *msg, int size)
        return result;
 }
 #else
-#define PyStr_FromFormat PyString_FromFormat
 #define PyStr_FromFormatV PyString_FromFormatV
 #define PyStr_AsUTF8 PyString_AsString
 #define PyLdbBytes_FromStringAndSize PyString_FromStringAndSize
@@ -597,7 +595,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)", PyStr_AsUTF8(repr));
        Py_DECREF(str);
        Py_DECREF(repr);
        return result;
@@ -2764,7 +2762,7 @@ 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);
 }
 
@@ -3306,7 +3304,7 @@ static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self)
        }
 
        if (element_str != NULL) {
-               ret = PyStr_FromFormat("MessageElement([%s])", element_str);
+               ret = PyUnicode_FromFormat("MessageElement([%s])", element_str);
                talloc_free(element_str);
        } else {
                ret = PyUnicode_FromString("MessageElement([])");
@@ -3781,7 +3779,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)", PyStr_AsUTF8(repr));
        Py_DECREF(repr);
        Py_DECREF(dict);
        return ret;
index b305b608f471f2b89397910e356637a411d8ecab..12c7325fcac340f590bb30a1165fdc6a7f7b1590 100644 (file)
 
 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);
 }
 
index ce671a92b9abb400b4250bfe7660746e499c69f9..74e80f95ec505fbcd284e1ef8380cd2a7e2bec9a 100644 (file)
 #include <tdb.h>
 
 #if PY_MAJOR_VERSION >= 3
-#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_FromFormat PyString_FromFormat
 #endif
 
 /* discard signature of 'func' in favour of 'target_sig' */
@@ -654,7 +651,7 @@ static PyObject *tdb_object_repr(PyTdbObject *self)
        if (tdb_get_flags(self->ctx) & TDB_INTERNAL) {
                return PyUnicode_FromString("Tdb(<internal>)");
        } else {
-               return PyStr_FromFormat("Tdb('%s')", tdb_name(self->ctx));
+               return PyUnicode_FromFormat("Tdb('%s')", tdb_name(self->ctx));
        }
 }
 
index bac7ae00d1672b429b5c017687317c252d12033e..b1d2206bf8f19a184b1f997c06e13670fd393ba5 100644 (file)
@@ -54,7 +54,6 @@
 
 /* Strings */
 
-#define PyStr_FromFormat PyUnicode_FromFormat
 #define PyStr_FromFormatV PyUnicode_FromFormatV
 #define PyStr_AsString PyUnicode_AsUTF8
 
index fe01de36fea558b63bbafa70e743f47b88c29976..a59dcbf970ccecb50d0adef4894897f14829b843 100644 (file)
@@ -41,7 +41,7 @@ static PyObject *py_lsa_String_repr(PyObject *py_self)
                const char *empty = "lsaString(None)";
                ret = PyUnicode_FromString(empty);
        } else {
-               ret = PyStr_FromFormat("lsaString('%s')", self->string);
+               ret = PyUnicode_FromFormat("lsaString('%s')", self->string);
        }
        return ret;
 }
index 5e6af484f26a5fd84c88841a9dd1bdb2cda07908..d3c91a46d6b51d8c911fb2535a94a375c5de186a 100644 (file)
@@ -78,7 +78,7 @@ static PyObject *py_GUID_repr(PyObject *py_self)
 {
        struct GUID *self = pytalloc_get_ptr(py_self);
        char *str = GUID_string(NULL, self);
-       PyObject *ret = PyStr_FromFormat("GUID('%s')", str);
+       PyObject *ret = PyUnicode_FromFormat("GUID('%s')", str);
        talloc_free(str);
        return ret;
 }
@@ -162,7 +162,7 @@ static PyObject *py_policy_handle_repr(PyObject *py_self)
 {
        struct policy_handle *self = pytalloc_get_ptr(py_self);
        char *uuid_str = GUID_string(NULL, &self->uuid);
-       PyObject *ret = PyStr_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
+       PyObject *ret = PyUnicode_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
        talloc_free(uuid_str);
        return ret;
 }
@@ -171,7 +171,7 @@ static PyObject *py_policy_handle_str(PyObject *py_self)
 {
        struct policy_handle *self = pytalloc_get_ptr(py_self);
        char *uuid_str = GUID_string(NULL, &self->uuid);
-       PyObject *ret = PyStr_FromFormat("%d, %s", self->handle_type, uuid_str);
+       PyObject *ret = PyUnicode_FromFormat("%d, %s", self->handle_type, uuid_str);
        talloc_free(uuid_str);
        return ret;
 }
index b9dd29310e6381905605541c4c946fa5daa6c1bf..b8d7c877694756cfb0ca8c2733c2a141562987b4 100644 (file)
@@ -124,7 +124,7 @@ static PyObject *py_dom_sid_repr(PyObject *py_self)
 {
        struct dom_sid *self = pytalloc_get_ptr(py_self);
        struct dom_sid_buf buf;
-       PyObject *ret = PyStr_FromFormat(
+       PyObject *ret = PyUnicode_FromFormat(
                "dom_sid('%s')", dom_sid_str_buf(self, &buf));
        return ret;
 }
index cf7423ddec3f769548d3871393a9270181690ae2..fc5965e624553ae154f0084176a2fe1b30a75ddc 100644 (file)
@@ -100,7 +100,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
     /* construct and return the right type of python object */
     switch (parm->type) {
     case P_CHAR:
-       return PyStr_FromFormat("%c", *(char *)parm_ptr);
+       return PyUnicode_FromFormat("%c", *(char *)parm_ptr);
     case P_STRING:
     case P_USTRING:
        return PyUnicode_FromString(*(char **)parm_ptr);
@@ -355,7 +355,7 @@ static PyObject *py_lp_log_level(PyObject *self, PyObject *unused)
 static PyObject *py_samdb_url(PyObject *self, PyObject *unused)
 {
        struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
-       return PyStr_FromFormat("tdb://%s/sam.ldb", lpcfg_private_dir(lp_ctx));
+       return PyUnicode_FromFormat("tdb://%s/sam.ldb", lpcfg_private_dir(lp_ctx));
 }
 
 static PyObject *py_cache_path(PyObject *self, PyObject *args)