From 11edfc55ea954174be05d902dae91bc96dfddd41 Mon Sep 17 00:00:00 2001 From: Fabian Kropfhamer <54098356+fkropfhamer@users.noreply.github.com> Date: Tue, 22 Dec 2020 17:49:57 +0100 Subject: [PATCH] added check if before reading file --- tweepy/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tweepy/api.py b/tweepy/api.py index a424a39..0df8da3 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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': -- 2.25.1