All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: openembedded-core@lists.openembedded.org
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Subject: [bitbake][PATCH] lib/bb/build.py: Raise proper KeyError if function does not exist
Date: Wed,  8 Feb 2017 07:17:53 +0100	[thread overview]
Message-ID: <1486534673-18706-1-git-send-email-mike.looijmans@topic.nl> (raw)
In-Reply-To: 9b8f8f39-aa5f-cbdf-8d45-9bd0e27c9404@topic.nl

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@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():
-- 
1.9.1



  parent reply	other threads:[~2017-02-08  6:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 14:21 (morty) Python exception during rootfs Mike Looijmans
2017-02-07 16:08 ` Mike Looijmans
2017-02-08  8:29   ` Patrick Ohly
2017-02-08  6:17 ` Mike Looijmans [this message]
2017-02-08 22:10   ` [bitbake][PATCH] lib/bb/build.py: Raise proper KeyError if function does not exist Paul Eggleton
2017-02-08  6:29 ` ✗ patchtest: failure for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486534673-18706-1-git-send-email-mike.looijmans@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.