Skip to contentSkip to conversation

scripts/oe-selftest: avoid deprecated imp.reload function

PATCH In review [email protected] 2 participants 4 messages May 2, 2017 – May 5, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/oe-selftest: avoid deprecated imp.reload function

From: Leonardo Sandoval <[email protected]>

As explained in [1], the module function imp.reload has been deprecated for importlib.reload, so use the latter instead.

[1] https://docs.python.org/3/library/imp.html#imp.reload

---
 scripts/oe-selftest | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/oe-selftest +2 -2
index 52366b1c8de..bbc161e649b 100755
@@ -35,7 +35,7 @@ import time as t
 import re
 import fnmatch
 import collections
-import imp
+import importlib
 
 sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib')
 import scriptpath
@@ -497,7 +497,7 @@ def main():
     bbpath = get_bb_var('BBPATH').split(':')
     layer_libdirs = [p for p in (os.path.join(l, 'lib') for l in bbpath) if os.path.exists(p)]
     sys.path.extend(layer_libdirs)
-    imp.reload(oeqa.selftest)
+    importlib.reload(oeqa.selftest)
 
     # act like bitbake and enforce en_US.UTF-8 locale
     os.environ["LC_ALL"] = "en_US.UTF-8"
Signature · 1 line
2.12.0
#1 lore raw
Quoted 3 lines · On 2 May 2017 at 18:37, <[email protected]> wrote:

As explained in [1], the module function imp.reload has been deprecated for importlib.reload, so use the latter instead.

$ oe-selftest -r package
2017-05-04 17:40:10,352 - selftest - INFO - Running bitbake -e to get BBPATH
Traceback (most recent call last):
  File "/home/ross/Yocto/poky/scripts/oe-selftest", line 806, in <module>
    ret = main()
  File "/home/ross/Yocto/poky/scripts/oe-selftest", line 500, in main
    importlib.reload(oeqa.selftest)
UnboundLocalError: local variable 'importlib' referenced before assignment

Ross

#2 lore raw
Quoted 8 lines · Ross

On 2 May 2017 at 18:37, <[email protected]> wrote:
As explained in [1], the module function imp.reload has been deprecated for
importlib.reload, so use the latter instead.

Quoted 12 lines
$ oe-selftest -r package
2017-05-04 17:40:10,352 - selftest - INFO - Running bitbake -e to get
BBPATH
Traceback (most recent call last):
  File "/home/ross/Yocto/poky/scripts/oe-selftest", line 806, in
<module>
    ret = main()
  File "/home/ross/Yocto/poky/scripts/oe-selftest", line 500, in main
    importlib.reload(oeqa.selftest)
UnboundLocalError: local variable 'importlib' referenced before
assignment

I saw the error also. The strange thing is that the import importlib has global scope but the interpreter does not have it visible at the 'main' function. any idea? will send a v2 once I figure out the latter.

Leo

Quoted 2 lines

Ross

#3 lore raw
Quoted 4 lines · Leonardo Sandoval

I saw the error also. The strange thing is that the import importlib has global scope but the interpreter does not have it visible at the 'main' function. any idea? will send a v2 once I figure out the latter.

I had a ten second look before mailing and decided that it was sufficiently weird to let you figure it out ;)

Ross