From c4d65f8bf4519cdae48fd0d80e87f7ae12cf2c6c Mon Sep 17 00:00:00 2001 From: Wirtos Date: Fri, 1 Mar 2019 22:27:15 +0200 Subject: [PATCH] ValueError fix for IOBase files (#1119) --- telethon/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 305e3e39..4df28dba 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -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)