diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-13 22:45:48 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-14 11:18:18 +0000 |
commit | 54bbe35eab3e8f3618024ca8d1b30ff1c425201f (patch) | |
tree | b5eeafef471abdc74bde074bbf45178744f7a8db /bitbake/lib/bb/utils.py | |
parent | 57e290371b00f6b695c6f3220f9860f0a16cd0c9 (diff) | |
download | poky-54bbe35eab3e8f3618024ca8d1b30ff1c425201f.tar.gz |
bitbake: utils: Avoid warnings about deprecated imp module
The imp module is deprecated, port the code over to use importlib.
bitbake/lib/bb/utils.py:30: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
(Bitbake rev: 3c2cb35588e91fbd7b136e5e2c78eeb77e126c84)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 73b6cb423b..461122bba1 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -27,7 +27,8 @@ import bb | |||
27 | import bb.msg | 27 | import bb.msg |
28 | import multiprocessing | 28 | import multiprocessing |
29 | import fcntl | 29 | import fcntl |
30 | import imp | 30 | import importlib |
31 | from importlib import machinery | ||
31 | import itertools | 32 | import itertools |
32 | import subprocess | 33 | import subprocess |
33 | import glob | 34 | import glob |
@@ -43,7 +44,7 @@ from contextlib import contextmanager | |||
43 | from ctypes import cdll | 44 | from ctypes import cdll |
44 | 45 | ||
45 | logger = logging.getLogger("BitBake.Util") | 46 | logger = logging.getLogger("BitBake.Util") |
46 | python_extensions = [e for e, _, _ in imp.get_suffixes()] | 47 | python_extensions = importlib.machinery.all_suffixes() |
47 | 48 | ||
48 | 49 | ||
49 | def clean_context(): | 50 | def clean_context(): |
@@ -1544,12 +1545,9 @@ def export_proxies(d): | |||
1544 | def load_plugins(logger, plugins, pluginpath): | 1545 | def load_plugins(logger, plugins, pluginpath): |
1545 | def load_plugin(name): | 1546 | def load_plugin(name): |
1546 | logger.debug(1, 'Loading plugin %s' % name) | 1547 | logger.debug(1, 'Loading plugin %s' % name) |
1547 | fp, pathname, description = imp.find_module(name, [pluginpath]) | 1548 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) |
1548 | try: | 1549 | if spec: |
1549 | return imp.load_module(name, fp, pathname, description) | 1550 | return spec.loader.load_module() |
1550 | finally: | ||
1551 | if fp: | ||
1552 | fp.close() | ||
1553 | 1551 | ||
1554 | logger.debug(1, 'Loading plugins from %s...' % pluginpath) | 1552 | logger.debug(1, 'Loading plugins from %s...' % pluginpath) |
1555 | 1553 | ||