diff options
author | Alexandre Flament <alex@al-f.net> | 2020-10-07 10:11:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 10:11:53 +0200 |
commit | 66bda238955bc899a70c688b746aafaf56813f32 (patch) | |
tree | 8161b6637b8c5971642221cb4fdae7e0e6e1e370 | |
parent | 584760cf5419051bd3f37e733147e048356f7ffc (diff) | |
parent | 8659212f5a3147bf71fa0205257709d11eebfe66 (diff) | |
download | searxng-66bda238955bc899a70c688b746aafaf56813f32.tar.gz searxng-66bda238955bc899a70c688b746aafaf56813f32.zip |
Merge pull request #2244 from dalf/fix-drop-python2
Fix drop python2
-rw-r--r-- | searx/engines/json_engine.py | 2 | ||||
-rw-r--r-- | searx/utils.py | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/searx/engines/json_engine.py b/searx/engines/json_engine.py index 1e5c39ac4..e2aa436cc 100644 --- a/searx/engines/json_engine.py +++ b/searx/engines/json_engine.py @@ -1,4 +1,4 @@ -from collections import Iterable +from collections.abc import Iterable from json import loads from urllib.parse import urlencode from searx.utils import to_string diff --git a/searx/utils.py b/searx/utils.py index 0be3c5b00..db17feba9 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -3,8 +3,8 @@ import os import sys import re import json +import importlib -from imp import load_source from numbers import Number from os.path import splitext, join from io import open @@ -445,8 +445,11 @@ def load_module(filename, module_dir): if modname in sys.modules: del sys.modules[modname] filepath = join(module_dir, filename) - module = load_source(modname, filepath) - module.name = modname + # and https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly + 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 |