]> jfr.im git - z_archive/twitter.git/commitdiff
Fix encoding errors on text sent along with pics under py2.7
authorRouxRC <redacted>
Mon, 22 Sep 2014 17:56:56 +0000 (19:56 +0200)
committerRouxRC <redacted>
Mon, 22 Sep 2014 17:56:56 +0000 (19:56 +0200)
twitter/api.py

index 5e6d20af50bb92a5f62e2cd86f8d4ed628350239..c176d57d437a96e3717ff0af5f999904508cc18c 100644 (file)
@@ -262,6 +262,11 @@ class TwitterCall(object):
             headers['Content-Type'] = \
                 'multipart/form-data; boundary=%s' % BOUNDARY
 
+        if sys.version_info[:2] == (2, 7):
+            uriBase = uriBase.encode("utf-8")
+            for k in headers:
+                headers[k.encode('utf-8')] = headers.pop(k)
+
         req = urllib_request.Request(uriBase, body, headers)
         return self._handle_response(req, uri, arg_data, _timeout)