From c3c95cb5f53fea2d8c0db83947b89a51e3be4fac Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Wed, 30 Oct 2024 13:29:44 +0100 Subject: [PATCH] fix(imp module): replace deprecated module imp module has been replaced by importlib in python 3.12 and is not available anymore Signed-off-by: Martin Basti --- atomic_reactor/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/atomic_reactor/plugin.py b/atomic_reactor/plugin.py index fc5459768..227c97c50 100644 --- a/atomic_reactor/plugin.py +++ b/atomic_reactor/plugin.py @@ -15,7 +15,7 @@ import os import sys import traceback -import imp # pylint: disable=deprecated-module +import importlib import inspect import time from abc import ABC, abstractmethod @@ -185,7 +185,9 @@ def load_plugins(self) -> Dict[str, Plugin]: f_module = sys.modules[module_name] else: try: - f_module = imp.load_source(module_name, f) + spec = importlib.util.spec_from_file_location(module_name, f) + f_module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(f_module) except (IOError, OSError, ImportError, SyntaxError) as ex: logger.warning("can't load module '%s': %s", f, ex) continue