summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantinos Koukopoulos <koukopoulos@gmail.com>2014-08-26 15:23:51 +0300
committerKonstantinos Koukopoulos <koukopoulos@gmail.com>2014-08-26 15:23:51 +0300
commit45bf3d0683bc3a0b9b87709ee09e39467bf53eb1 (patch)
treef6ccad23574643a3dee0e23222a576836d96251a
parent2b87583140206185e35ee3918a263081235db785 (diff)
downloadboto-45bf3d0683bc3a0b9b87709ee09e39467bf53eb1.tar.gz
support non-ascii unicode strings in _get_all_query_args. Fixes: #2558
-rw-r--r--boto/s3/bucket.py2
-rw-r--r--tests/unit/s3/test_bucket.py6
2 files changed, 6 insertions, 2 deletions
diff --git a/boto/s3/bucket.py b/boto/s3/bucket.py
index 34514078..4aac7526 100644
--- a/boto/s3/bucket.py
+++ b/boto/s3/bucket.py
@@ -377,6 +377,8 @@ class Bucket(object):
key = 'max-keys'
if not isinstance(value, six.string_types + (six.binary_type,)):
value = six.text_type(value)
+ if not isinstance(value, six.binary_type):
+ value = value.encode('utf-8')
if value != '':
pairs.append(u'%s=%s' % (
urllib.parse.quote(key),
diff --git a/tests/unit/s3/test_bucket.py b/tests/unit/s3/test_bucket.py
index 3dc5f6e3..72e10ed2 100644
--- a/tests/unit/s3/test_bucket.py
+++ b/tests/unit/s3/test_bucket.py
@@ -92,6 +92,8 @@ class TestS3Bucket(AWSMockServiceTestCase):
'foo': 'true',
# Ensure Unicode chars get encoded.
'bar': '☃',
+ # Ensure unicode strings with non-ascii characters get encoded
+ 'baz': u'χ',
# Underscores are bad, m'kay?
'some_other': 'thing',
# Change the variant of ``max-keys``.
@@ -104,14 +106,14 @@ class TestS3Bucket(AWSMockServiceTestCase):
qa = bukket._get_all_query_args(multiple_params)
self.assertEqual(
qa,
- 'bar=%E2%98%83&foo=true&max-keys=0&some-other=thing'
+ 'bar=%E2%98%83&baz=%CF%87&foo=true&max-keys=0&some-other=thing'
)
# Multiple params with initial.
qa = bukket._get_all_query_args(multiple_params, 'initial=1')
self.assertEqual(
qa,
- 'initial=1&bar=%E2%98%83&foo=true&max-keys=0&some-other=thing'
+ 'initial=1&bar=%E2%98%83&baz=%CF%87&foo=true&max-keys=0&some-other=thing'
)
@patch.object(S3Connection, 'head_bucket')