]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
get_module_deps3.py: Check attribute '__file__'
authorLeon Anavi <leon.anavi@konsulko.com>
Wed, 2 Nov 2022 19:18:00 +0000 (21:18 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 7 Nov 2022 14:32:39 +0000 (14:32 +0000)
Check if the module object has attribute '__file__' to fix and
avoid errors like:

AttributeError: module '_abc' has no attribute '__file__'. Did you mean: '__name__'?

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
meta/recipes-devtools/python/python3/get_module_deps3.py

index 1f4c982aedafc64689883032e2617a7bca1cfffa..0ca687d2eb3f83e5ab19000e1e4dc1deb757c503 100644 (file)
@@ -56,7 +56,7 @@ if debug == True:
 try:
     m = importlib.import_module(current_module)
     # handle python packages which may not include all modules in the __init__
-    if os.path.basename(m.__file__) == "__init__.py":
+    if hasattr(m, '__file__') and os.path.basename(m.__file__) == "__init__.py":
         modulepath = os.path.dirname(m.__file__)
         for i in os.listdir(modulepath):
             if i.startswith("_") or not(i.endswith(".py")):