Skip to contentSkip to conversation

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

PATCH New Richard Purdie 1 participant 1 message Jan 4, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: Update to use exec_module() instead of load_module()

This is deprecated in python 3.12 and Fedora 35 is throwing warnings so move to the new functions.

---
 lib/bb/utils.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/bb/utils.py +3 -1
index 8006f7bd2d..a288f9bb8c 100644
@@ -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)
 
Signature · 1 line
2.32.0