From d7ac5d850dfa093fd3a031b966d9de25731eb3bb Mon Sep 17 00:00:00 2001 From: Katsunori SUZUI Date: Fri, 13 Jun 2014 18:00:02 +0900 Subject: [PATCH] Fix tweepy.API.update_with_media If filename is an instance of `unicode', L.76 `` 'Content-Disposition: form-data; name="%s"; filename="%s"' % (form_field, filename) '' must be unicode string. Because of it, L. 803 `` body = '\r\n'.join(body) '' fails. Therefore, I made `filename' designed to be percent-encoded str object before formatting. --- tweepy/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tweepy/api.py b/tweepy/api.py index 9e3d64e..9218208 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -4,6 +4,7 @@ import os import mimetypes +import urllib from tweepy.binder import bind_api from tweepy.error import TweepError @@ -788,6 +789,8 @@ class API(object): if file_type not in ['image/gif', 'image/jpeg', 'image/png']: raise TweepError('Invalid file type for image: %s' % file_type) + if isinstance(filename, unicode): + filename = urllib.quote(filename.encode("utf-8")) BOUNDARY = 'Tw3ePy' -- 2.25.1