From: Ross Burton Date: Wed, 20 Oct 2021 17:30:06 +0000 (+0100) Subject: oeqa/runtime: load modules using importlib X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~6352 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f501d22eab5dbd565f3f5783f4f484a6d1f70a2;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git oeqa/runtime: load modules using importlib Instead of using __import__() which is low-level and discouraged, use importlib. Signed-off-by: Ross Burton Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py index 3826f276421..7908ce1fd46 100644 --- a/meta/lib/oeqa/runtime/context.py +++ b/meta/lib/oeqa/runtime/context.py @@ -175,16 +175,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): # Search for and return a controller or None from given module name @staticmethod def _loadControllerFromModule(target, modulename): - obj = None - # import module, allowing it to raise import exception - module = __import__(modulename, globals(), locals(), [target]) - # look for target class in the module, catching any exceptions as it - # is valid that a module may not have the target class. try: - obj = getattr(module, target) - except: - obj = None - return obj + import importlib + module = importlib.import_module(modulename) + return getattr(module, target) + except AttributeError: + return None @staticmethod def readPackagesManifest(manifest):