Patchwork [bitbake-devel] Fix support for anonymous methods in foobar_%.bbappend files

login
register
mail settings
Submitter Jacob Kroon
Date Feb. 21, 2014, 4:46 p.m.
Message ID <1393001163-7170-1-git-send-email-jacob.kroon@mikrodidakt.se>
Download mbox | patch
Permalink /patch/67123/
State New
Headers show

Comments

Jacob Kroon - Feb. 21, 2014, 4:46 p.m.
When using wildcard .bbappend files with anonymous methods in them,
bitbake/python fails to parse the generated code since the '%' is encoded
in the generated method name.

Fix this by including '%' in the convert-to-underscore list during
method name mangling.

[YOCTO #5864]

Signed-off-by: Jacob Kroon <jacob.kroon@mikrodidakt.se>
---
 lib/bb/parse/ast.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Chris Larson - Feb. 22, 2014, 4:14 a.m.
On Fri, Feb 21, 2014 at 9:46 AM, Jacob Kroon <jacob.kroon@mikrodidakt.se>wrote:

> -            funcname = ("__anon_%s_%s" % (self.lineno,
> self.filename.translate(string.maketrans('/.+-@', '_____'))))
> +            funcname = ("__anon_%s_%s" % (self.lineno,
> self.filename.translate(string.maketrans('/.+-@%', '______'))))
>

I know it's not related to this particular patch, but there's no reason for
us to call string.maketrans() inside of MethodPool.eval(), that should
probably have been a class member, no reason to regenerate the translation
table every time, after all :)

Patch

diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py
index a202053..8331b59 100644
--- a/lib/bb/parse/ast.py
+++ b/lib/bb/parse/ast.py
@@ -147,7 +147,7 @@  class MethodNode(AstNode):
     def eval(self, data):
         text = '\n'.join(self.body)
         if self.func_name == "__anonymous":
-            funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-@', '_____'))))
+            funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-@%', '______'))))
             text = "def %s(d):\n" % (funcname) + text
             bb.methodpool.insert_method(funcname, text, self.filename)
             anonfuncs = data.getVar('__BBANONFUNCS') or []