Fix media is-file check

This commit is contained in:
Lorenz Diener 2018-11-26 11:42:19 +01:00
pare ae9640e95d
commit d1717be251

Veure arxiu

@ -1495,7 +1495,7 @@ class Mastodon:
# Load avatar, if specified
if not avatar is None:
if avatar_mime_type is None and os.path.isfile(avatar):
if avatar_mime_type is None and (isinstance(avatar, str) and os.path.isfile(avatar)):
avatar_mime_type = guess_type(avatar)
avatar = open(avatar, 'rb')
@ -1504,7 +1504,7 @@ class Mastodon:
# Load header, if specified
if not header is None:
if header_mime_type is None and os.path.isfile(header):
if header_mime_type is None and (isinstance(avatar, str) and os.path.isfile(header)):
header_mime_type = guess_type(header)
header = open(header, 'rb')
@ -1724,10 +1724,10 @@ class Mastodon:
Returns a `media dict`_. This contains the id that can be used in
status_post to attach the media file to a toot.
"""
if mime_type is None and os.path.isfile(media_file):
if mime_type is None and (isinstance(media_file, str) and os.path.isfile(media_file)):
mime_type = guess_type(media_file)
media_file = open(media_file, 'rb')
elif mime_type and os.path.isfile(media_file):
elif isinstance(media_file, str) and os.path.isfile(media_file):
media_file = open(media_file, 'rb')
if mime_type is None: