utils: Update to use exec_module() instead of load_module()

Message ID 20220104231132.1383733-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 68a18fbcb5959e334cf307d7fa8dc63832edb942
Headers show
Series utils: Update to use exec_module() instead of load_module() | expand

Commit Message

Richard Purdie Jan. 4, 2022, 11:11 p.m. UTC
This is deprecated in python 3.12 and Fedora 35 is throwing warnings so
move to the new functions.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/utils.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 8006f7bd2d..a288f9bb8c 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1651,7 +1651,9 @@  def load_plugins(logger, plugins, pluginpath):
         logger.debug('Loading plugin %s' % name)
         spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] )
         if spec:
-            return spec.loader.load_module()
+            mod = importlib.util.module_from_spec(spec)
+            spec.loader.exec_module(mod)
+            return mod
 
     logger.debug('Loading plugins from %s...' % pluginpath)