Fix media is-file check
This commit is contained in:
pare
ae9640e95d
commit
d1717be251
S'han modificat 1 arxius amb 4 adicions i 4 eliminacions
|
@ -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:
|
||||
|
|
Loading…
Referencia en una nova incidència