From d6f6df20455e9c346bd68f78eaff5327fcb5e8b8 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Sun, 6 Sep 2009 15:48:58 -0400 Subject: [PATCH] Force any methods that handle image uploading to open the image (for encoding) as a Binary file, was doing ASCII before (oddly, this wasn't caught until now. Major thanks to Yoav Aviram for pointing this out. :D --- twython.py | 4 ++-- twython3k.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/twython.py b/twython.py index 5afadf0..dd0cd27 100644 --- a/twython.py +++ b/twython.py @@ -1257,7 +1257,7 @@ class setup: """ if self.authenticated is True: try: - files = [("image", filename, open(filename).read())] + files = [("image", filename, open(filename, 'rb').read())] fields = [] content_type, body = self.encode_multipart_formdata(fields, files) headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} @@ -1278,7 +1278,7 @@ class setup: """ if self.authenticated is True: try: - files = [("image", filename, open(filename).read())] + files = [("image", filename, open(filename, 'rb').read())] fields = [] content_type, body = self.encode_multipart_formdata(fields, files) headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} diff --git a/twython3k.py b/twython3k.py index 2c34ab9..08db6ad 100644 --- a/twython3k.py +++ b/twython3k.py @@ -1257,7 +1257,7 @@ class setup: """ if self.authenticated is True: try: - files = [("image", filename, open(filename).read())] + files = [("image", filename, open(filename, 'rb').read())] fields = [] content_type, body = self.encode_multipart_formdata(fields, files) headers = {'Content-Type': content_type, 'Content-Length': str(len(body))} @@ -1278,7 +1278,7 @@ class setup: """ if self.authenticated is True: try: - files = [("image", filename, open(filename).read())] + files = [("image", filename, open(filename, 'rb').read())] fields = [] content_type, body = self.encode_multipart_formdata(fields, files) headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}