txaws-dev team mailing list archive
-
txaws-dev team
-
Mailing list archive
-
Message #00085
[Merge] lp:~therve/txaws/ec2-unicode into lp:txaws
Thomas Herve has proposed merging lp:~therve/txaws/ec2-unicode into lp:txaws.
Requested reviews:
txAWS Technical List (txaws-tech)
Related bugs:
Bug #920915 in txAWS: "Support unicode parameters to the EC2 client"
https://bugs.launchpad.net/txaws/+bug/920915
For more details, see:
https://code.launchpad.net/~therve/txaws/ec2-unicode/+merge/89859
A fairly simple localized change I hope, which fixes the problem we have in Landscape and CloudDeck with 2.7.
--
https://code.launchpad.net/~therve/txaws/ec2-unicode/+merge/89859
Your team txAWS Technical List is requested to review the proposed merge of lp:~therve/txaws/ec2-unicode into lp:txaws.
=== modified file 'txaws/ec2/client.py'
--- txaws/ec2/client.py 2011-08-19 16:09:39 +0000
+++ txaws/ec2/client.py 2012-01-24 11:12:28 +0000
@@ -963,7 +963,8 @@
@ivar creds: The L{AWSCredentials} to use to compute the signature.
@ivar endpoint: The {AWSServiceEndpoint} to consider.
- @ivar params: A C{dict} of parameters to consider.
+ @ivar params: A C{dict} of parameters to consider. They should be byte
+ strings, but unicode strings are supported and will be encode in UTF-8.
"""
def __init__(self, creds, endpoint, params):
@@ -1016,6 +1017,8 @@
See the AWS dev reference page 90 (2008-12-01 version).
@return: a_string encoded.
"""
+ if isinstance(string, unicode):
+ string = string.encode("utf-8")
return quote(string, safe="~")
def sorted_params(self):
=== modified file 'txaws/ec2/tests/test_client.py'
--- txaws/ec2/tests/test_client.py 2011-08-29 19:51:50 +0000
+++ txaws/ec2/tests/test_client.py 2012-01-24 11:12:28 +0000
@@ -1735,6 +1735,15 @@
signature = client.Signature(self.creds, self.endpoint, self.params)
self.assertEqual("a%20space", signature.encode("a space"))
+ def test_encode_unicode(self):
+ """
+ L{Signature.encode} accepts unicode strings and encode them un UTF-8.
+ """
+ signature = client.Signature(self.creds, self.endpoint, self.params)
+ self.assertEqual(
+ "f%C3%A9e",
+ signature.encode(u"f\N{LATIN SMALL LETTER E WITH ACUTE}e"))
+
def test_canonical_query(self):
signature = client.Signature(self.creds, self.endpoint, self.params)
time_tuple = (2007, 11, 12, 13, 14, 15, 0, 0, 0)