From: RouxRC Date: Mon, 22 Sep 2014 17:56:56 +0000 (+0200) Subject: Fix encoding errors on text sent along with pics under py2.7 X-Git-Tag: twitter-1.16.0~27 X-Git-Url: https://jfr.im/git/z_archive/twitter.git/commitdiff_plain/f5ca09ad9948af4d475fc92279a072d6fcfee545 Fix encoding errors on text sent along with pics under py2.7 --- diff --git a/twitter/api.py b/twitter/api.py index 5e6d20a..c176d57 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -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)