From a016fa35362a9ccc00f78aa46d24a64a507eb5a1 Mon Sep 17 00:00:00 2001 From: Jakub Rozek Date: Fri, 24 Nov 2023 12:28:20 +0100 Subject: [PATCH] Use importlib instead of imp `imp` module is removed in python3.12 --- lnst/Agent/Agent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lnst/Agent/Agent.py b/lnst/Agent/Agent.py index d8b33db82..e2c3fa395 100644 --- a/lnst/Agent/Agent.py +++ b/lnst/Agent/Agent.py @@ -11,6 +11,7 @@ jpirko@redhat.com (Jiri Pirko) """ +import importlib.machinery import signal import logging import os, stat @@ -19,7 +20,6 @@ import socket import ctypes import multiprocessing -import imp import types from time import sleep from inspect import isclass @@ -161,7 +161,8 @@ def load_cached_module(self, module_name, res_hash): if module_name in self._dynamic_modules: return module_path = self._cache.get_path(res_hash) - module = imp.load_source(module_name, module_path) + module_loader = importlib.machinery.SourceFileLoader(module_name, module_path) + module = module_loader.load_module() self._dynamic_modules[module_name] = module def init_cls(self, cls_name, module_name, args, kwargs):