aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2018-11-26 11:42:19 +0100
committerLorenz Diener <[email protected]>2018-11-26 11:42:19 +0100
commitd1717be251295ed766fda03bd9c8535459bfc404 (patch)
tree9f6dae689ef9221c60a52c918f8daab79d221d2c /mastodon
parentae9640e95d2cfa43e1a35d8281fe38a671fdc71d (diff)
downloadmastodon.py-d1717be251295ed766fda03bd9c8535459bfc404.tar.gz
Fix media is-file check
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py8
1 files changed, 4 insertions, 4 deletions
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:
1495 1495
1496 # Load avatar, if specified 1496 # Load avatar, if specified
1497 if not avatar is None: 1497 if not avatar is None:
1498 if avatar_mime_type is None and os.path.isfile(avatar): 1498 if avatar_mime_type is None and (isinstance(avatar, str) and os.path.isfile(avatar)):
1499 avatar_mime_type = guess_type(avatar) 1499 avatar_mime_type = guess_type(avatar)
1500 avatar = open(avatar, 'rb') 1500 avatar = open(avatar, 'rb')
1501 1501
@@ -1504,7 +1504,7 @@ class Mastodon:
1504 1504
1505 # Load header, if specified 1505 # Load header, if specified
1506 if not header is None: 1506 if not header is None:
1507 if header_mime_type is None and os.path.isfile(header): 1507 if header_mime_type is None and (isinstance(avatar, str) and os.path.isfile(header)):
1508 header_mime_type = guess_type(header) 1508 header_mime_type = guess_type(header)
1509 header = open(header, 'rb') 1509 header = open(header, 'rb')
1510 1510
@@ -1724,10 +1724,10 @@ class Mastodon:
1724 Returns a `media dict`_. This contains the id that can be used in 1724 Returns a `media dict`_. This contains the id that can be used in
1725 status_post to attach the media file to a toot. 1725 status_post to attach the media file to a toot.
1726 """ 1726 """
1727 if mime_type is None and os.path.isfile(media_file): 1727 if mime_type is None and (isinstance(media_file, str) and os.path.isfile(media_file)):
1728 mime_type = guess_type(media_file) 1728 mime_type = guess_type(media_file)
1729 media_file = open(media_file, 'rb') 1729 media_file = open(media_file, 'rb')
1730 elif mime_type and os.path.isfile(media_file): 1730 elif isinstance(media_file, str) and os.path.isfile(media_file):
1731 media_file = open(media_file, 'rb') 1731 media_file = open(media_file, 'rb')
1732 1732
1733 if mime_type is None: 1733 if mime_type is None:
Powered by cgit v1.2.3 (git 2.41.0)