bitbake:main.py: Handle RuntimeError exception in list_extension_modules
PATCH 1/1 bitbake:main.py: Handle RuntimeError exception in list_extension_modules
It seems to just be an exception that was missed that can occur during import and would cause bitbake to completely fail.
--- bitbake/lib/bb/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/main.py +1 -1
@@ -60,7 +60,7 @@ def list_extension_modules(pkg, checkattr): continue try: module = __import__(pkg.__name__, fromlist=[modulename]) - except (ImportError, SystemExit): + except (ImportError, SystemExit, RuntimeError): # If we can't import it, it's not valid continue module_if = getattr(module, modulename)
Signature · 1 line
2.4.3
bitbake/lib/bb/main.py def list_extension_modules(pkg, checkattr): · line 66
Quoted 11 lines · Randy Witt
bitbake/lib/bb/main.py +1
-1@@ -60,7 +60,7 @@ def list_extension_modules(pkg, checkattr): continue try: module = __import__(pkg.__name__, fromlist=[modulename]) - except (ImportError, SystemExit): + except (ImportError, SystemExit, RuntimeError): # If we can't import it, it's not valid continue module_if = getattr(module, modulename)
Wouldn't it be better to just skip naming the exceptions you want to catch in this case? I.e.:
try:
module = __import__(...
except:
continue
"If we can't import it" ...
Signature · 1 line
olofjn
Quoted 21 lines · On Friday 21 August 2015 00:51:44 Olof Johansson wrote:
Quoted 15 lines · Randy Witt
bitbake/lib/bb/main.py +1
-1@@ -60,7 +60,7 @@ def list_extension_modules(pkg, checkattr): continue try: module = __import__(pkg.__name__, fromlist=[modulename]) - except (ImportError, SystemExit): + except (ImportError, SystemExit, RuntimeError):# If we can't import it, it's not valid continue
Quoted 1 line
module_if=getattr(module, modulename)Wouldn't it be better to just skip naming the exceptions you want to catch in this case? I.e.:
Quoted 6 lines
try: module = __import__(... except: continue"If we can't import it" ...
As a matter of good practice I try to avoid eating all exceptions that way in case one of them is a genuine error rather than something we want to ignore. Maybe this is a reasonable exception (heh) though.
FWIW we might consider just reverting my change if it's causing too much greif.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 27 lines · Paul Eggleton
Quoted 26 lines · On Friday 21 August 2015 00:51:44 Olof Johansson wrote:
Quoted 15 lines · Randy Witt
bitbake/lib/bb/main.py +1
-1@@ -60,7 +60,7 @@ def list_extension_modules(pkg, checkattr): continue try: module = __import__(pkg.__name__, fromlist=[modulename]) - except (ImportError, SystemExit): + except (ImportError, SystemExit, RuntimeError):# If we can't import it, it's not valid continue
Quoted 1 line
module_if=getattr(module, modulename)Wouldn't it be better to just skip naming the exceptions you want to catch in this case? I.e.:
try: module = __import__(... except: continue
Quoted 5 lines
Quoted 1 line
"If we can't import it" ...
As a matter of good practice I try to avoid eating all exceptions that way in case one of them is a genuine error rather than something we want to ignore. Maybe this is a reasonable exception (heh) though.
I think in this case, a generic except might be a better alternative. I agree in general its a bad idea. I merged the other fix since it got us around the issue whilst we could consider what to do about it.
Quoted 2 lines
FWIW we might consider just reverting my change if it's causing too much greif.
I think I'd be happier if it only tried to import the UIs if --help were specified. How you do that with python argument handling I'm less sure of though...
Cheers,
Richard