Fix Telethon could not be imported without sqlite3

Closes #4723.
This commit is contained in:
Lonami Exo
2025-12-18 17:44:05 +01:00
parent 664ceba2c5
commit 05b8488858

View File

@@ -9,7 +9,16 @@ import typing
import logging
import warnings
from collections import deque
import sqlite3
try:
import sqlite3
OperationalError = sqlite3.OperationalError
except ImportError as e:
sqlite3 = None
class OperationalError(Exception):
pass # won't be created and thus never caught
from .. import events, utils, errors
from ..events.common import EventBuilder, EventCommon
@@ -325,7 +334,7 @@ class UpdateMethods:
await self.disconnect()
break
continue
except (errors.TypeNotFoundError, sqlite3.OperationalError) as e:
except (errors.TypeNotFoundError, OperationalError) as e:
# User is likely doing weird things with their account or session and Telegram gets confused as to what layer they use
self._log[__name__].warning('Cannot get difference since the account is likely misusing the session: %s', e)
self._message_box.end_difference()
@@ -368,7 +377,7 @@ class UpdateMethods:
await self.disconnect()
break
continue
except (errors.TypeNotFoundError, sqlite3.OperationalError) as e:
except (errors.TypeNotFoundError, OperationalError) as e:
self._log[__name__].warning(
'Cannot get difference for channel %s since the account is likely misusing the session: %s',
get_diff.channel.channel_id, e