mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Raise ImportError and not ValueError when sqlite3 is missing
Excepting ValueError when creating the SQLiteSession could hide other errors (e.g. using a newer session file on an older version of the library). Instead, the original error is raised, as if sqlite3 was being imported within its __init__ method.
This commit is contained in:
parent
d25442345e
commit
47d9de98ed
|
@ -202,7 +202,7 @@ class TelegramBaseClient(abc.ABC):
|
|||
if isinstance(session, str) or session is None:
|
||||
try:
|
||||
session = SQLiteSession(session)
|
||||
except ValueError:
|
||||
except ImportError:
|
||||
import warnings
|
||||
warnings.warn(
|
||||
'The sqlite3 module is not available under this '
|
||||
|
|
|
@ -14,8 +14,10 @@ from ..tl.types import (
|
|||
|
||||
try:
|
||||
import sqlite3
|
||||
except ImportError:
|
||||
sqlite3_err = None
|
||||
except ImportError as e:
|
||||
sqlite3 = None
|
||||
sqlite3_err = type(e)
|
||||
|
||||
EXTENSION = '.session'
|
||||
CURRENT_VERSION = 5 # database version
|
||||
|
@ -32,7 +34,7 @@ class SQLiteSession(MemorySession):
|
|||
|
||||
def __init__(self, session_id=None):
|
||||
if sqlite3 is None:
|
||||
raise ValueError('sqlite3 is not installed')
|
||||
raise sqlite3_err
|
||||
|
||||
super().__init__()
|
||||
self.filename = ':memory:'
|
||||
|
|
Loading…
Reference in New Issue
Block a user