[OE-core] [bitbake][PATCH] lib/bb/build.py: Raise proper KeyError if function does not exist
Paul Eggleton
paul.eggleton at linux.intel.com
Wed Feb 8 22:10:52 UTC 2017
Hi Mike,
On Wednesday, 8 February 2017 7:17:53 AM NZDT Mike Looijmans wrote:
> If one adds the following line to an image recipe without defining
> the function:
> ROOTFS_POSTPROCESS_COMMAND += "rootfs_funky_stuff;"
> bitbake will terminate with a cryptic error message:
> AttributeError: 'NoneType' object has no attribute 'get'
>
> To inform the user of what bitbake wasn't able to find, raise a KeyError
> exception denoting the function name before that happens. This changes the
> message to the much more useful:
> KeyError: 'rootfs_funky_stuff'
>
> Signed-off-by: Mike Looijmans <mike.looijmans at topic.nl>
> ---
> lib/bb/build.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/bb/build.py b/lib/bb/build.py
> index c4c8aeb..5bc18c1 100644
> --- a/lib/bb/build.py
> +++ b/lib/bb/build.py
> @@ -194,6 +194,8 @@ def exec_func(func, d, dirs = None,
> pythonexception=False): oldcwd = None
>
> flags = d.getVarFlags(func)
> + if flags is None:
> + raise KeyError(func)
> cleandirs = flags.get('cleandirs')
> if cleandirs:
> for cdir in d.expand(cleandirs).split():
This should got to the bitbake-devel list.
Whilst I agree this is an improvement, since we're trying to print a more
reasonable error message, wouldn't we be better off explicitly saying
"Function %s not defined" or similar?
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
More information about the Openembedded-core
mailing list