Replace deprecated imp by importlib
This commit is contained in:
parent
30663f2113
commit
47f392ef70
@ -372,13 +372,9 @@ class BasePluginManager:
|
|||||||
Reloads modules that might not be in the path.
|
Reloads modules that might not be in the path.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
import imp
|
spec = importlib.util.find_spec(pdata.mod_name, [pdata.fpath])
|
||||||
fp, pathname, description = imp.find_module(pdata.mod_name, [pdata.fpath])
|
module = importlib.util.module_from_spec(spec)
|
||||||
try:
|
spec.loader.exec_module(module)
|
||||||
module = imp.load_module(pdata.mod_name, fp, pathname,description)
|
|
||||||
finally:
|
|
||||||
if fp:
|
|
||||||
fp.close()
|
|
||||||
except:
|
except:
|
||||||
if pdata.mod_name in sys.modules:
|
if pdata.mod_name in sys.modules:
|
||||||
del sys.modules[pdata.mod_name]
|
del sys.modules[pdata.mod_name]
|
||||||
|
@ -47,8 +47,8 @@ from gramps.gen.utils.libformatting import ImportInfo
|
|||||||
# a quick turnround, without having to restart Gramps.
|
# a quick turnround, without having to restart Gramps.
|
||||||
module = __import__("gramps.plugins.lib.libgedcom",
|
module = __import__("gramps.plugins.lib.libgedcom",
|
||||||
fromlist=["gramps.plugins.lib"]) # why o why ?? as above!
|
fromlist=["gramps.plugins.lib"]) # why o why ?? as above!
|
||||||
import imp
|
import importlib
|
||||||
imp.reload(module)
|
importlib.reload(module)
|
||||||
|
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user