Keystone exceptions inherited from keystone.exception.Error can only take acsii message as the message arguments to construct exception instances.
Because keystone.exception.Error inherits from StandardError which in cpython, has a somewhat "buggy" implementation of __unicode__ as following,
static PyObject *
BaseException_unicode(PyBaseExceptionObject *self)
{
PyObject *out;
/* issue6108: if __str__ has been overridden in the subclass, unicode()
should return the message returned by __str__ as used to happen
before this method was implemented. */
if (Py_TYPE(self)->tp_str != (reprfunc)BaseException_str) {
PyObject *str;
/* Unlike PyObject_Str, tp_str can return unicode (i.e. return the
equivalent of unicode(e.__str__()) instead of unicode(str(e))). */
str = Py_TYPE(self)->tp_str((PyObject*)self);
if (str == NULL)
return NULL;
out = PyObject_Unicode(str);
Py_DECREF(str);
return out;
}
switch (PyTuple_GET_SIZE(self->args)) {
case 0:
out = PyUnicode_FromString("");
break;
case 1:
out = PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0));
break;
default:
out = PyObject_Unicode(self->args);
break;
}
return out;
}
thus that whenever keystone.exception.Error.__unicode__ is called, the call will be forwarded to keystone.exception.Error.__str__. And it will cause problem if its error message is unicode string.
Fix proposed to branch: master /review. openstack. org/26923
Review: https:/