Support pathlib.Path as session again

See #3737.
This commit is contained in:
Lonami Exo 2024-02-13 18:18:52 +01:00
parent 39fc5c5fef
commit 2b99ff65c5

View File

@ -7,6 +7,7 @@ import platform
import time
import typing
import datetime
import pathlib
from .. import version, helpers, __name__ as __base_name__
from ..crypto import rsa
@ -235,7 +236,7 @@ class TelegramBaseClient(abc.ABC):
def __init__(
self: 'TelegramClient',
session: 'typing.Union[str, Session]',
session: 'typing.Union[str, pathlib.Path, Session]',
api_id: int,
api_hash: str,
*,
@ -284,9 +285,9 @@ class TelegramBaseClient(abc.ABC):
self._log = _Loggers()
# Determine what session object we have
if isinstance(session, str) or session is None:
if isinstance(session, (str, pathlib.Path)) or session is None:
try:
session = SQLiteSession(session)
session = SQLiteSession(str(session))
except ImportError:
import warnings
warnings.warn(