From: Andrew Bartlett Date: Sat, 14 Mar 2020 21:43:16 +0000 (+1300) Subject: py3: Remove #define IsPy3BytesOrString(pystr) X-Git-Tag: ldb-2.2.0~1275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7633deb8978e2417430692223047283baf30147;p=thirdparty%2Fsamba.git py3: Remove #define IsPy3BytesOrString(pystr) 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 Reviewed-by: Noel Power --- diff --git a/python/py3compat.h b/python/py3compat.h index 516495e4e5a..d09947bf90d 100644 --- a/python/py3compat.h +++ b/python/py3compat.h @@ -55,17 +55,6 @@ /* 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) \ diff --git a/source4/librpc/ndr/py_misc.c b/source4/librpc/ndr/py_misc.c index 81e762af328..2ee62ca7db4 100644 --- a/source4/librpc/ndr/py_misc.c +++ b/source4/librpc/ndr/py_misc.c @@ -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; }