Fix TelegramClient init with None session (#4339)

This commit is contained in:
Lindsay Zhou 2024-03-30 14:10:12 +00:00 committed by GitHub
parent 75d609ab2a
commit 9f3e7e4aa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -285,7 +285,7 @@ class TelegramBaseClient(abc.ABC):
self._log = _Loggers()
# Determine what session object we have
if isinstance(session, (str, pathlib.Path)) or session is None:
if isinstance(session, (str, pathlib.Path)):
try:
session = SQLiteSession(str(session))
except ImportError:
@ -298,6 +298,8 @@ class TelegramBaseClient(abc.ABC):
'you use another session storage'
)
session = MemorySession()
elif session is None:
session = MemorySession()
elif not isinstance(session, Session):
raise TypeError(
'The given session must be a str or a Session instance.'