[bitbake-devel] [PATCH] bitbake:main.py: Handle RuntimeError exception in list_extension_modules

Richard Purdie richard.purdie at linuxfoundation.org
Fri Aug 21 16:53:05 UTC 2015


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




More information about the bitbake-devel mailing list