diff --git a/bin/heat-api b/bin/heat-api index 3f9eeeabd9..d9f7495e22 100755 --- a/bin/heat-api +++ b/bin/heat-api @@ -33,7 +33,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): from heat.openstack.common import gettextutils -gettextutils.install('heat', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('heat', lazy=True) from oslo.config import cfg diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn index 03a14028b2..54bdf637f7 100755 --- a/bin/heat-api-cfn +++ b/bin/heat-api-cfn @@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): from heat.openstack.common import gettextutils -gettextutils.install('heat', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('heat', lazy=True) from oslo.config import cfg diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch index 9100e878e9..79feb70a9f 100755 --- a/bin/heat-api-cloudwatch +++ b/bin/heat-api-cloudwatch @@ -35,7 +35,8 @@ if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): from heat.openstack.common import gettextutils -gettextutils.install('heat', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('heat', lazy=True) from oslo.config import cfg diff --git a/bin/heat-engine b/bin/heat-engine index 6f05e167c1..185d48ee1f 100755 --- a/bin/heat-engine +++ b/bin/heat-engine @@ -36,7 +36,8 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'heat', '__init__.py')): from heat.openstack.common import gettextutils -gettextutils.install('heat', lazy=False) +gettextutils.enable_lazy() +gettextutils.install('heat', lazy=True) from oslo.config import cfg diff --git a/heat/common/exception.py b/heat/common/exception.py index b196f6d53a..6f2150fd41 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -119,11 +119,14 @@ class HeatException(Exception): raise exc_info[0], exc_info[1], exc_info[2] def __str__(self): - return str(self.message) + return unicode(self.message).encode('UTF-8') def __unicode__(self): return unicode(self.message) + def __deepcopy__(self, memo): + return self.__class__(**self.kwargs) + class MissingCredentialError(HeatException): msg_fmt = _("Missing required credential: %(required)s") diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 7773e55696..e9596b72ae 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -758,7 +758,7 @@ def log_exception(err, exc_info): def translate_exception(exc, locale): """Translates all translatable elements of the given exception.""" - exc.message = gettextutils.translate(str(exc), locale) + exc.message = gettextutils.translate(unicode(exc), locale) if isinstance(exc, webob.exc.HTTPError): # If the explanation is not a Message, that means that the # explanation is the default, generic and not translatable explanation @@ -767,7 +767,7 @@ def translate_exception(exc, locale): # message, since message is what gets passed in at construction time # in the API if not isinstance(exc.explanation, gettextutils.Message): - exc.explanation = str(exc) + exc.explanation = unicode(exc) exc.detail = '' else: exc.explanation = \