py3: Remove #define IsPy3BytesOrString(pystr)
authorAndrew Bartlett <abartlet@samba.org>
Sat, 14 Mar 2020 21:43:16 +0000 (10:43 +1300)
committerNoel Power <npower@samba.org>
Mon, 23 Mar 2020 19:12:43 +0000 (19:12 +0000)
This was

  (PyUnicode_Check(pystr) || PyBytes_Check(pystr))

This allows us to end the use of Python 2/3 compatability macros.

The one caller will be simplified in the next commit

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <nopower@samba.org>
python/py3compat.h
source4/librpc/ndr/py_misc.c

index 516495e4e5ac32a309d372c5fbe94b418a245783..d09947bf90d61b63e81aa3891a123f22b8b8186a 100644 (file)
 /* description of bytes objects */
 #define PY_DESC_PY3_BYTES "bytes"
 
-/* Determine if object is really bytes, for code that runs
- * in python2 & python3 (note: PyBytes_Check is replaced by
- * PyString_Check in python2) so care needs to be taken when
- * writing code that will check if incoming type is bytes that
- * will work as expected in python2 & python3
- */
-
-#define IsPy3BytesOrString(pystr) \
-    (PyUnicode_Check(pystr) || PyBytes_Check(pystr))
-
-
 /* Module init */
 
 #define MODULE_INIT_FUNC(name) \
index 81e762af3281ac5b559ee27482c4086886a99d13..2ee62ca7db49a5ae132da5a1bf3af03124a58047 100644 (file)
@@ -97,7 +97,7 @@ static int py_GUID_init(PyObject *self, PyObject *args, PyObject *kwargs)
                DATA_BLOB guid_val;
                Py_ssize_t _size;
 
-               if (!IsPy3BytesOrString(str) && !PyUnicode_Check(str)) {
+               if (!(PyUnicode_Check(str) || PyBytes_Check(str)) && !PyUnicode_Check(str)) {
                        PyErr_SetString(PyExc_TypeError, "Expected a string or bytes argument to GUID()");
                        return -1;
                }