Convert parse error to text type

Some local environments (but not yet the gate) are experiencing
failure of InstantiationDataTest.test_format_parse_invalid_message.

This change fixes that test by converting the parse exception to
a text type before including it in the error message.

Change-Id: I06e271559e27452a7a0c1e8807a37bb5ed5df2fa
Closes-Bug: #1365880
This commit is contained in:
Steve Baker 2014-09-24 10:43:44 +12:00
parent 689ea2742e
commit 58a094238b

View File

@ -15,6 +15,7 @@
Stack endpoint for Heat v1 ReST API. Stack endpoint for Heat v1 ReST API.
""" """
import six
from six.moves.urllib import parse from six.moves.urllib import parse
from webob import exc from webob import exc
@ -79,7 +80,7 @@ class InstantiationData(object):
else: else:
return template_format.parse(data) return template_format.parse(data)
except ValueError as parse_ex: except ValueError as parse_ex:
mdict = {'type': data_type, 'error': parse_ex} mdict = {'type': data_type, 'error': six.text_type(parse_ex)}
msg = _("%(type)s not in valid format: %(error)s") % mdict msg = _("%(type)s not in valid format: %(error)s") % mdict
raise exc.HTTPBadRequest(msg) raise exc.HTTPBadRequest(msg)