From: Leon Anavi Date: Wed, 2 Nov 2022 19:18:00 +0000 (+0200) Subject: get_module_deps3.py: Check attribute '__file__' X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~2638 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8acce12c1a4cf37ac312c92d62a6ae93a349dddf;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git get_module_deps3.py: Check attribute '__file__' 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 Signed-off-by: Alexandre Belloni --- diff --git a/meta/recipes-devtools/python/python3/get_module_deps3.py b/meta/recipes-devtools/python/python3/get_module_deps3.py index 1f4c982aeda..0ca687d2eb3 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")):