diff options
Diffstat (limited to 'ironic/common/exception.py')
-rw-r--r-- | ironic/common/exception.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ironic/common/exception.py b/ironic/common/exception.py index e5630990c..4cdbb03dd 100644 --- a/ironic/common/exception.py +++ b/ironic/common/exception.py @@ -128,10 +128,12 @@ class IronicException(Exception): def __str__(self): """Encode to utf-8 then wsme api can consume it as well.""" - if not six.PY3: - return six.text_type(self.args[0]).encode('utf-8') - - return self.args[0] + value = self.__unicode__() + if six.PY3: + # On Python 3 unicode is the same as str + return value + else: + return value.encode('utf-8') def __unicode__(self): """Return a unicode representation of the exception message.""" |