mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 04:39:26 +01:00
conf: Use imports instead of sys.modules to detect module availability
`conf.supybot.databases()` may be called without any plugin supporting sqlite3 being loaded yet, which causes `sqlite3` to be missing from `sys.modules`; so it wouldn't be used by plugins loaded afterward.
This commit is contained in:
parent
d58d8d4a71
commit
862fca1602
12
src/conf.py
12
src/conf.py
@ -1021,9 +1021,17 @@ class Databases(registry.SpaceSeparatedListOfStrings):
|
||||
v = super(Databases, self).__call__()
|
||||
if not v:
|
||||
v = ['anydbm', 'dbm', 'cdb', 'flat', 'pickle']
|
||||
if 'sqlalchemy' in sys.modules:
|
||||
try:
|
||||
import sqlalchemy
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
v.insert(0, 'sqlalchemy')
|
||||
if 'sqlite3' in sys.modules:
|
||||
try:
|
||||
import sqlite3
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
v.insert(0, 'sqlite3')
|
||||
return v
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user