diff --git a/heat/engine/parameters.py b/heat/engine/parameters.py index c20d82444c..944a57c8dc 100644 --- a/heat/engine/parameters.py +++ b/heat/engine/parameters.py @@ -15,9 +15,11 @@ import collections import itertools import json +import six from heat.engine import constraints as constr from heat.common import exception +from heat.openstack.common import strutils PARAMETER_KEYS = ( @@ -251,7 +253,7 @@ class Parameter(object): if self.hidden(): return '******' else: - return str(value) + return strutils.safe_encode(six.text_type(value)) class NumberParam(Parameter): diff --git a/heat/tests/test_parameters.py b/heat/tests/test_parameters.py index d91343dc2c..8413fd4e0b 100644 --- a/heat/tests/test_parameters.py +++ b/heat/tests/test_parameters.py @@ -164,6 +164,11 @@ class ParameterTest(testtools.TestCase): p = self.new_parameter('p', schema, 'bar') self.assertEqual('bar', p.value()) + def test_string_value_unicode(self): + schema = {'Type': 'String'} + p = self.new_parameter('p', schema, u'test\u2665') + self.assertEqual(u'test\u2665', p.value()) + def test_string_value_list_bad(self): schema = {'Type': 'String', 'ConstraintDescription': 'wibble', @@ -375,13 +380,17 @@ class ParametersTest(testtools.TestCase): def test_map_str(self): template = {'Parameters': {'Foo': {'Type': 'String'}, - 'Bar': {'Type': 'Number'}}} + 'Bar': {'Type': 'Number'}, + 'Uni': {'Type': 'String'}}} stack_name = 'test_params' params = self.new_parameters(stack_name, template, - {'Foo': 'foo', 'Bar': '42'}) + {'Foo': 'foo', + 'Bar': '42', + 'Uni': u'test\u2665'}) expected = {'Foo': 'foo', 'Bar': '42', + 'Uni': 'test\xe2\x99\xa5', 'AWS::Region': 'ap-southeast-1', 'AWS::StackId': 'arn:openstack:heat:::stacks/{0}/{1}'.format(