mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
refactor module loading to use exec_module: load_module is deprecated;
closes gh-4126
This commit is contained in:
parent
edaf8ef19f
commit
7528fce11b
1 changed files with 4 additions and 2 deletions
|
|
@ -29,6 +29,7 @@ import subprocess
|
|||
import sys
|
||||
from threading import Lock
|
||||
import time
|
||||
import types
|
||||
from ..helpers import getLogger, _merge_dicts, uni_decode
|
||||
from collections import OrderedDict
|
||||
|
||||
|
|
@ -352,6 +353,7 @@ class Utils():
|
|||
def load_python_module(pythonModule):
|
||||
pythonModuleName = os.path.splitext(
|
||||
os.path.basename(pythonModule))[0]
|
||||
mod = importlib.machinery.SourceFileLoader(
|
||||
pythonModuleName, pythonModule).load_module()
|
||||
ldr = importlib.machinery.SourceFileLoader(pythonModuleName, pythonModule)
|
||||
mod = types.ModuleType(ldr.name)
|
||||
ldr.exec_module(mod)
|
||||
return mod
|
||||
|
|
|
|||
Loading…
Reference in a new issue