* [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules
@ 2015-08-20 21:00 Randy Witt
2015-08-20 22:51 ` Olof Johansson
0 siblings, 1 reply; 4+ messages in thread
From: Randy Witt @ 2015-08-20 21:00 UTC (permalink / raw)
To: bitbake-devel
It seems to just be an exception that was missed that can occur during
import and would cause bitbake to completely fail.
Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
---
bitbake/lib/bb/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index c98cf44..910cd64 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -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)
--
2.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules
2015-08-20 21:00 [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules Randy Witt
@ 2015-08-20 22:51 ` Olof Johansson
2015-08-21 8:07 ` Paul Eggleton
0 siblings, 1 reply; 4+ messages in thread
From: Olof Johansson @ 2015-08-20 22:51 UTC (permalink / raw)
To: Randy Witt, bitbake-devel
On 15-08-20 23:00 +0200, Randy Witt wrote:
> --- a/bitbake/lib/bb/main.py
> +++ b/bitbake/lib/bb/main.py
> @@ -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" ...
--
olofjn
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules
2015-08-20 22:51 ` Olof Johansson
@ 2015-08-21 8:07 ` Paul Eggleton
2015-08-21 16:53 ` Richard Purdie
0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggleton @ 2015-08-21 8:07 UTC (permalink / raw)
To: Olof Johansson; +Cc: bitbake-devel
On Friday 21 August 2015 00:51:44 Olof Johansson wrote:
> On 15-08-20 23:00 +0200, Randy Witt wrote:
> > --- a/bitbake/lib/bb/main.py
> > +++ b/bitbake/lib/bb/main.py
> >
> > @@ -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" ...
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
--
Paul Eggleton
Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules
2015-08-21 8:07 ` Paul Eggleton
@ 2015-08-21 16:53 ` Richard Purdie
0 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2015-08-21 16:53 UTC (permalink / raw)
To: Paul Eggleton; +Cc: bitbake-devel
On Fri, 2015-08-21 at 09:07 +0100, Paul Eggleton wrote:
> On Friday 21 August 2015 00:51:44 Olof Johansson wrote:
> > On 15-08-20 23:00 +0200, Randy Witt wrote:
> > > --- a/bitbake/lib/bb/main.py
> > > +++ b/bitbake/lib/bb/main.py
> > >
> > > @@ -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" ...
>
> 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.
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-21 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 21:00 [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules Randy Witt
2015-08-20 22:51 ` Olof Johansson
2015-08-21 8:07 ` Paul Eggleton
2015-08-21 16:53 ` Richard Purdie
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.