From c47f501c45e49e3419e1202ae50694eaf829f436 Mon Sep 17 00:00:00 2001 From: Mitch Garnaat Date: Tue, 14 Jan 2014 07:53:56 -0800 Subject: [PATCH] Fixing an issue that came up while fixing https://github.com/aws/aws-cli/issues/593. --- botocore/parameters.py | 4 +++- tests/unit/test_parameters.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/botocore/parameters.py b/botocore/parameters.py index e8f97d27d1..4e6b49ea53 100644 --- a/botocore/parameters.py +++ b/botocore/parameters.py @@ -79,7 +79,9 @@ def store_value_query(self, value, built_params, label): label = label.format(label=self.get_label()) else: label = self.get_label() - built_params[label] = str(value) + if not isinstance(value, six.text_type): + value = str(value) + built_params[label] = value def build_parameter_query(self, value, built_params, label=''): value = self.validate(value) diff --git a/tests/unit/test_parameters.py b/tests/unit/test_parameters.py index 7215b9daec..74a2ee0757 100644 --- a/tests/unit/test_parameters.py +++ b/tests/unit/test_parameters.py @@ -105,6 +105,16 @@ def test_string(self): p.build_parameter_query(value=1, built_params=d) + def test_utf8_string(self): + p = botocore.parameters.StringParameter(None, name='foo') + d = {} + value = '\u65e5\u672c\u8a9e' + p.build_parameter_query(value, d) + self.assertEqual(d['foo'], value) + with self.assertRaises(botocore.exceptions.ValidationError): + p.build_parameter_query(value=1, + built_params=d) + def test_integer(self): p = botocore.parameters.IntegerParameter(None, name='foo') d = {}