forked from zaclys/searxng
[fix] drop Python 2: use importlib instead of imp.load_source
imp.load_source is not documented in Python 3 see documentation : https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly partial fix of https://github.com/searx/searx/issues/1674
This commit is contained in:
parent
584760cf54
commit
15013e64d8
|
@ -3,8 +3,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import importlib
|
||||||
|
|
||||||
from imp import load_source
|
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
from os.path import splitext, join
|
from os.path import splitext, join
|
||||||
from io import open
|
from io import open
|
||||||
|
@ -445,8 +445,11 @@ def load_module(filename, module_dir):
|
||||||
if modname in sys.modules:
|
if modname in sys.modules:
|
||||||
del sys.modules[modname]
|
del sys.modules[modname]
|
||||||
filepath = join(module_dir, filename)
|
filepath = join(module_dir, filename)
|
||||||
module = load_source(modname, filepath)
|
# and https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
|
||||||
module.name = modname
|
spec = importlib.util.spec_from_file_location(modname, filepath)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
sys.modules[modname] = module
|
||||||
|
spec.loader.exec_module(module)
|
||||||
return module
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue