added check if before reading file
authorFabian Kropfhamer <54098356+fkropfhamer@users.noreply.github.com>
Tue, 22 Dec 2020 16:49:57 +0000 (17:49 +0100)
committerGitHub <noreply@github.com>
Tue, 22 Dec 2020 16:49:57 +0000 (17:49 +0100)
tweepy/api.py

index a424a394e6f53a25b918161a09c45f3fa188bf88..0df8da3b2ec5e0eb9d57e1792f50a0cb29075ddf 100644 (file)
@@ -220,7 +220,9 @@ class API(object):
             :allowed_param:
         """
         f = kwargs.pop('file', None)
-        h = f.read(32)
+        h = None
+        if f:
+            h = f.read(32)
 
         file_type = imghdr.what(filename, h=h) or mimetypes.guess_type(filename)[0]
         if file_type == 'gif':