refactor module loading to use exec_module: load_module is deprecated;

closes gh-4126
This commit is contained in:
Sergey G. Brester 2026-01-01 21:43:27 +01:00 committed by GitHub
parent edaf8ef19f
commit 7528fce11b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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