carolinux / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
0 stars 1 forks source link

Atom.url.Url.get_param_string can not handle unicode parms #644

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
following patch might helps:

diff -r a8c25010b8b7 src/atom/url.py
--- a/src/atom/url.py   Mon Aug 27 13:50:08 2012 -0700
+++ b/src/atom/url.py   Thu Oct 25 19:47:55 2012 +0800
@@ -87,10 +87,17 @@
     return urlparse.urlunparse(url_parts)

   def get_param_string(self):
+    def _str(s):
+      if isinstance(s, unicode):
+        s = s.encode('utf-8', 'ignore')
+      else:
+        s = str(s)
+      return s
+            
     param_pairs = []
     for key, value in self.params.iteritems():
       param_pairs.append('='.join((urllib.quote_plus(key), 
-          urllib.quote_plus(str(value)))))
+          urllib.quote_plus(_str(value)))))
     return '&'.join(param_pairs)

   def get_request_uri(self):

Original issue reported on code.google.com by george...@gmail.com on 25 Oct 2012 at 11:49