py3: Remove PyStr_Check() compatability macro
authorAndrew Bartlett <abartlet@samba.org>
Fri, 7 Jun 2019 08:39:11 +0000 (10:39 +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/ldb/pyldb_util.c
lib/tevent/pytevent.c
libcli/nbt/pynbt.c
python/py3compat.h
source4/auth/pyauth.c
source4/librpc/rpc/pyrpc.c
source4/param/pyparam.c
source4/param/pyparam_util.c

index 940e43e3192288f640fdb448ecf600ada9435889..7487753c12d49142f4bd95322e30f4ada4b254fb 100644 (file)
@@ -85,7 +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
@@ -106,7 +105,6 @@ 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
@@ -1157,7 +1155,7 @@ 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) || PyUnicode_Check(item))) {
                        PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
                        talloc_free(ret);
                        return NULL;
index 46ee40341228a0dd0f5b3b70d5a7678b84c0581a..b153d878351fff0295730ba026a63d12a8fe182d 100644 (file)
 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
 
@@ -70,7 +68,7 @@ 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))) {
+       if (ldb_ctx != NULL && (PyUnicode_Check(object) || PyUnicode_Check(object))) {
                odn = ldb_dn_new(mem_ctx, ldb_ctx, PyStr_AsUTF8(object));
                *dn = odn;
                return true;
index a73141bf87d1fa9a91bb9f859143a0d50f05df27..50252836b695b9e55a39f6fb9454ef9d0e9ef2ee 100644 (file)
 #include <tevent.h>
 
 #if PY_MAJOR_VERSION >= 3
-#define PyStr_Check PyUnicode_Check
 #define PyStr_FromString PyUnicode_FromString
 #define PyStr_AsUTF8 PyUnicode_AsUTF8
 #define PyInt_FromLong PyLong_FromLong
 #else
-#define PyStr_Check PyString_Check
 #define PyStr_FromString PyString_FromString
 #define PyStr_AsUTF8 PyString_AsString
 #endif
@@ -191,7 +189,7 @@ static PyObject *py_register_backend(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       if (!(PyStr_Check(name) || PyUnicode_Check(name))) {
+       if (!(PyUnicode_Check(name) || PyUnicode_Check(name))) {
                PyErr_SetNone(PyExc_TypeError);
                Py_DECREF(name);
                return NULL;
index 2ae3ecfe8a736c7b8bdc9d453d3454e6bd10281f..4134c4344a6f0eabef1a53c931597aec3d0914dd 100644 (file)
@@ -57,7 +57,7 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *
 
 static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, uint16_t *dest_port)
 {
-       if (PyStr_Check(obj) || PyUnicode_Check(obj)) {
+       if (PyUnicode_Check(obj) || PyUnicode_Check(obj)) {
                *dest_addr = PyStr_AsString(obj);
                *dest_port = NBT_NAME_SERVICE_PORT;
                return true;
@@ -69,7 +69,7 @@ static bool PyObject_AsDestinationTuple(PyObject *obj, const char **dest_addr, u
                        return false;
                }
 
-               if (!(PyStr_Check(PyTuple_GetItem(obj, 0)) || PyUnicode_Check(PyTuple_GetItem(obj, 0)))) {
+               if (!(PyUnicode_Check(PyTuple_GetItem(obj, 0)) || PyUnicode_Check(PyTuple_GetItem(obj, 0)))) {
                        PyErr_SetString(PyExc_TypeError, "Destination tuple first element not string");
                        return false;
                }
@@ -126,7 +126,7 @@ static bool PyObject_AsNBTName(PyObject *obj, struct nbt_name_socket *name_socke
                }
        }
 
-       if (PyStr_Check(obj) || PyUnicode_Check(obj)) {
+       if (PyUnicode_Check(obj) || PyUnicode_Check(obj)) {
                /* FIXME: Parse string to be able to interpret things like RHONWYN<02> ? */
                name->name = PyStr_AsString(obj);
                if (name->name == NULL) {
index a66e940001d148dbe5909ff2fef0252c196505d5..9a98339d9160d20ca5a2abb688e76a2e523b20f7 100644 (file)
@@ -54,7 +54,6 @@
 
 /* Strings */
 
-#define PyStr_Check PyUnicode_Check
 #define PyStr_FromString PyUnicode_FromString
 #define PyStr_FromStringAndSize PyUnicode_FromStringAndSize
 #define PyStr_FromFormat PyUnicode_FromFormat
@@ -77,7 +76,7 @@
 #define IsPy3Bytes PyBytes_Check
 
 #define IsPy3BytesOrString(pystr) \
-    (PyStr_Check(pystr) || PyBytes_Check(pystr))
+    (PyUnicode_Check(pystr) || PyBytes_Check(pystr))
 
 
 /* Ints */
index acda96612af5e97dcf4aea099c122cbe12347cd0..b4963e8eab6c70c60e921b8bf5ea2ca8ecde92f0 100644 (file)
@@ -301,7 +301,7 @@ static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
                const char *value;
                Py_ssize_t size;
                PyObject *item = PyList_GetItem(list, i);
-               if (!(PyStr_Check(item) || PyUnicode_Check(item))) {
+               if (!(PyUnicode_Check(item) || PyUnicode_Check(item))) {
                        PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
                        return NULL;
                }
index 5d10201bb7072c3270465b65c3ce5e08d979f66c..90c890d2a0c1965523b33a7f84cf6abc8e334e70 100644 (file)
@@ -53,7 +53,7 @@ static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *sy
 {
        ZERO_STRUCTP(syntax_id);
 
-       if (PyStr_Check(object) || PyUnicode_Check(object)) {
+       if (PyUnicode_Check(object) || PyUnicode_Check(object)) {
                return PyString_AsGUID(object, &syntax_id->uuid);
        } else if (PyTuple_Check(object)) {
                PyObject *item = NULL;
@@ -63,7 +63,7 @@ static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *sy
                }
 
                item = PyTuple_GetItem(object, 0);
-               if (!(PyStr_Check(item) || PyUnicode_Check(item))) {
+               if (!(PyUnicode_Check(item) || PyUnicode_Check(item))) {
                        PyErr_SetString(PyExc_ValueError, "Expected GUID as first element in tuple");
                        return false;
                }
index 200162ea29ea1fdbd15bcddf4431ed62fc1a051b..df0879a3c714d30e2767fb5155f3c452bfc3ca07 100644 (file)
@@ -534,7 +534,7 @@ static Py_ssize_t py_lp_ctx_len(PyObject *self)
 static PyObject *py_lp_ctx_getitem(PyObject *self, PyObject *name)
 {
        struct loadparm_service *service;
-       if (!(PyStr_Check(name) || PyUnicode_Check(name))) {
+       if (!(PyUnicode_Check(name) || PyUnicode_Check(name))) {
                PyErr_SetString(PyExc_TypeError, "Only string subscripts are supported");
                return NULL;
        }
index 917caf809e50d09b6250f37253b826f0bda88213..7bde8c9c7140407f642053298f836d2b6520915f 100644 (file)
@@ -34,7 +34,7 @@ _PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyOb
        PyTypeObject *lp_type;
        bool is_lpobj;
 
-       if (PyStr_Check(py_obj) || PyUnicode_Check(py_obj)) {
+       if (PyUnicode_Check(py_obj) || PyUnicode_Check(py_obj)) {
                lp_ctx = loadparm_init_global(false);
                if (lp_ctx == NULL) {
                        return NULL;