mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Fix utils._get_extension not working in pathlib objects
This was found while testing #1371.
This commit is contained in:
@@ -12,6 +12,7 @@ import logging
|
||||
import math
|
||||
import mimetypes
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import struct
|
||||
from collections import namedtuple
|
||||
@@ -741,6 +742,8 @@ def _get_extension(file):
|
||||
"""
|
||||
if isinstance(file, str):
|
||||
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 ''
|
||||
|
Reference in New Issue
Block a user