ValueError fix for IOBase files (#1119)

This commit is contained in:
Wirtos
2019-03-01 22:27:15 +02:00
committed by Lonami
parent df534585e9
commit c4d65f8bf4

View File

@@ -649,8 +649,8 @@ def _get_extension(file):
kind = imghdr.what(io.BytesIO(file))
return ('.' + kind) if kind else ''
elif isinstance(file, io.IOBase) and file.seekable():
kind = imghdr.what(file) is not None
return ('.' + kind) if kind else ''
kind = imghdr.what(file)
return ('.' + kind) if kind is not None else ''
elif getattr(file, 'name', None):
# Note: ``file.name`` works for :tl:`InputFile` and some `IOBase`
return _get_extension(file.name)