From bd11564579c57c10757a9d841923d7f6968af204 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 20 Sep 2023 18:30:46 +0200 Subject: [PATCH] Remove uses of imghdr It's deprecated. Closes #4207. --- telethon/utils.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index f47912e1..ab78d8a4 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -4,7 +4,6 @@ to convert between an entity like a User, Chat, etc. into its Input version) """ import base64 import binascii -import imghdr import inspect import io import itertools @@ -835,12 +834,6 @@ def _get_extension(file): return os.path.splitext(file)[-1] elif isinstance(file, pathlib.Path): return file.suffix - elif isinstance(file, bytes): - kind = imghdr.what(io.BytesIO(file)) - return ('.' + kind) if kind else '' - elif isinstance(file, io.IOBase) and not isinstance(file, io.TextIOBase) and file.seekable(): - 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)