* [PATCH] get_module_deps3.py: Check attribute '__file__'
@ 2022-11-02 19:18 Leon Anavi
0 siblings, 0 replies; only message in thread
From: Leon Anavi @ 2022-11-02 19:18 UTC (permalink / raw)
To: openembedded-core; +Cc: Leon Anavi
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>
---
meta/recipes-devtools/python/python3/get_module_deps3.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/python/python3/get_module_deps3.py b/meta/recipes-devtools/python/python3/get_module_deps3.py
index 1f4c982aed..0ca687d2eb 100644
--- a/meta/recipes-devtools/python/python3/get_module_deps3.py
+++ b/meta/recipes-devtools/python/python3/get_module_deps3.py
@@ -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")):
--
2.30.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-02 19:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 19:18 [PATCH] get_module_deps3.py: Check attribute '__file__' Leon Anavi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.