1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-03 18:16:17 +01:00

Merge pull request #1114 from dmach/replace-imp-with-importlib

Replace imp with importlib
This commit is contained in:
Daniel Mach 2022-08-23 08:29:34 +02:00 committed by GitHub
commit 31b804eeec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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):