From 1b5b5a4edc011a2c9f1f44f4d90a5f7f5f9af2cf Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Mon, 3 Feb 2014 15:12:35 -0600 Subject: [PATCH] Remove use of str() in utils.misc.Failure Recent updates to gettextutils in OpenStack add the ability to translate errors in REST API responses. The new gettextutils code, however, requires that the error strings passed to it be unicode, not basestrings. A basetring being sent from str() results in an exception being raised. This change switches from using str() to six.text_type() in utils.misc.Failure to avoid problems after moving Cinder to use the new lazy translation support. Change-Id: I9a1e0ba714e9f3d214269c0f69726b0a1d1a4c7c closes-bug: 1275895 --- taskflow/utils/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/taskflow/utils/misc.py b/taskflow/utils/misc.py index da84d1a0..e14bc86f 100644 --- a/taskflow/utils/misc.py +++ b/taskflow/utils/misc.py @@ -444,7 +444,7 @@ def are_equal_exc_info_tuples(ei1, ei2): if ei1[0] is not ei2[0]: return False if not all((type(ei1[1]) == type(ei2[1]), - str(ei1[1]) == str(ei2[1]), + six.text_type(ei1[1]) == six.text_type(ei2[1]), repr(ei1[1]) == repr(ei2[1]))): return False if ei1[2] == ei2[2]: @@ -470,7 +470,7 @@ class Failure(object): reflection.get_all_class_names(exc_info[0], up_to=Exception)) if not self._exc_type_names: raise TypeError('Invalid exception type: %r' % exc_info[0]) - self._exception_str = str(self._exc_info[1]) + self._exception_str = six.text_type(self._exc_info[1]) self._traceback_str = ''.join( traceback.format_tb(self._exc_info[2])) else: