diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index a5c05b7..a0cf907 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -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: