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.
import os
import mimetypes
+import urllib
from tweepy.binder import bind_api
from tweepy.error import TweepError
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'