mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 19:08:44 +00:00
replace deprecated use of SourceFileLoader.load_module
This commit is contained in:
parent
779677bcc6
commit
94d28831e1
@ -24,12 +24,14 @@ def load_script(actx, path):
|
||||
# the fullname is not unique among scripts, so if there already is an existing script with said
|
||||
# fullname, remove it.
|
||||
sys.modules.pop(fullname, None)
|
||||
loader = importlib.machinery.SourceFileLoader(fullname, path)
|
||||
try:
|
||||
oldpath = sys.path
|
||||
sys.path.insert(0, os.path.dirname(path))
|
||||
with addonmanager.safecall():
|
||||
m = loader.load_module()
|
||||
loader = importlib.machinery.SourceFileLoader(fullname, path)
|
||||
spec = importlib.util.spec_from_loader(fullname, loader=loader)
|
||||
m = importlib.util.module_from_spec(spec)
|
||||
loader.exec_module(m)
|
||||
if not getattr(m, "name", None):
|
||||
m.name = path
|
||||
return m
|
||||
|
Loading…
Reference in New Issue
Block a user