Skip to contentSkip to conversation

tinfoil.py: validate argument in parse_recipe_file

PATCH In review Juro Bystricky 3 participants 4 messages Apr 5, 2017 – Apr 6, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tinfoil.py: validate argument in parse_recipe_file

Check for an empty file name to avoid an exception.

[YOCTO#11210]

---
 bitbake/lib/bb/tinfoil.py | 2 ++
 1 file changed, 2 insertions(+)
bitbake/lib/bb/tinfoil.py +2 -0
index 928333a..620f409 100644
@@ -399,6 +399,8 @@ class Tinfoil:
                          specify config_data then you cannot use a virtual
                          specification for fn.
         """
+        if not fn:
+            return None
         if appends and appendlist == []:
             appends = False
         if config_data:
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Juro Bystricky

Check for an empty file name to avoid an exception.

[YOCTO#11210]

IMO this is pointless. If you’re calling parse_recipe_file with an empty string, it’s programmer error, which means raising an exception is a completely reasonable thing to do.

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
#2 lore raw

parse_recipe can be called from parse_recipe_file as well. If parse_recipe_file is called with a non-existing recipe, you end up with the exception as well. IMHO for a non-existent recipe parse_recipe should return None (instead of an exception)

________________________________
From: Christopher Larson [[email protected]]
Sent: Wednesday, April 05, 2017 6:32 PM
To: Bystricky, Juro
Cc: [email protected]
Subject: Re: [bitbake-devel] [PATCH] tinfoil.py: validate argument in parse_recipe_file

On Wed, Apr 5, 2017 at 2:33 PM, Juro Bystricky <[email protected]<mailto:[email protected]>> wrote:
Check for an empty file name to avoid an exception.

[YOCTO#11210]

IMO this is pointless. If you’re calling parse_recipe_file with an empty string, it’s programmer error, which means raising an exception is a completely reasonable thing to do. --
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics

#3 lore raw
Quoted 4 lines · Juro

parse_recipe can be called from parse_recipe_file as well. If parse_recipe_file is called with a non-existing recipe, you end up with the exception as well. IMHO for a non-existent recipe parse_recipe should return None (instead of an exception)

I'm not sure I agree - an exception under these circumstances seems completely reasonable to me as well.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre