summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-04-13 17:17:20 +0100
committerNoel Power <npower@samba.org>2018-04-30 15:43:19 +0200
commit702e85e48fc4972714c57683f4c7b1daf775bd5c (patch)
tree82db5c7fc22928241fe889d81b136aaeb7a22f4a
parentdb8da077ec5d2b23f2219dd8d667c85d38f56ca8 (diff)
downloadsamba-702e85e48fc4972714c57683f4c7b1daf775bd5c.tar.gz
lib/tevent: Additionally accept unicode as string param in Py2
With the changes to make samba python code Py2/Py3 compatible there now are many instances where string content is decoded. Decoded string variables in Py2 are returned as the unicode type. Many Py2 c-module functions that take string arguments only check for the string type. However now it's quite possibe the content formally passed as a string argument is now passed as unicode after being decoded, such arguments are rejected and code can fail subtly. This only affects places where the type is directly checked e.g. via PyStr_Check etc. arguments that are parsed by ParseTuple* functions generally already accept both string and unicode (if 's', 'z', 's*' format specifiers are used) Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
-rw-r--r--lib/tevent/pytevent.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c
index 10d8a22a8cf..369ec6e02c8 100644
--- a/lib/tevent/pytevent.c
+++ b/lib/tevent/pytevent.c
@@ -188,7 +188,7 @@ static PyObject *py_register_backend(PyObject *self, PyObject *args)
return NULL;
}
- if (!PyStr_Check(name)) {
+ if (!(PyStr_Check(name) || PyUnicode_Check(name))) {
PyErr_SetNone(PyExc_TypeError);
Py_DECREF(name);
return NULL;