diff options
author | Ross Burton <ross@burtonini.com> | 2021-10-20 18:30:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-23 17:41:46 +0100 |
commit | 9f501d22eab5dbd565f3f5783f4f484a6d1f70a2 (patch) | |
tree | 5766019ac4d66375bd876dfcf5581fd8ae487e69 /meta/lib | |
parent | f6e7445c94443544e92fda97a017ce93393c5f84 (diff) | |
download | openembedded-core-9f501d22eab5dbd565f3f5783f4f484a6d1f70a2.tar.gz |
oeqa/runtime: load modules using importlib
Instead of using __import__() which is low-level and discouraged, use
importlib.
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/runtime/context.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py index 3826f27642..7908ce1fd4 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): |