1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

Replace imp with importlib

This commit is contained in:
Daniel Mach 2022-08-22 15:45:25 +02:00
parent 565797d5a7
commit ddec088efc

View File

@ -3,7 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or version 3 (at your option).
import imp
import importlib.util
import inspect
import os
import sys
@ -9431,8 +9431,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not extfile.endswith('.py'):
continue
try:
modname = os.path.splitext(extfile)[0]
mod = imp.load_source(modname, os.path.join(plugin_dir, extfile))
modname = "osc.plugins." + os.path.splitext(extfile)[0]
spec = importlib.util.spec_from_file_location(modname, os.path.join(plugin_dir, extfile))
mod = importlib.util.module_from_spec(spec)
sys.modules[modname] = mod
spec.loader.exec_module(mod)
# restore the old exec semantic
mod.__dict__.update(globals())
for name in dir(mod):