parse/ast.py: MethodNode fix character mapping error
PATCH 1/1 parse/ast.py: MethodNode fix character mapping error
When found an anonymous function the func name is made by filename and lineno, the filename need to be converted to string before using translation because produces an error of encoding.
--- lib/bb/parse/ast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/parse/ast.py +1 -1
@@ -149,7 +149,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(MethodNode.tr_tbl))) + funcname = ("__anon_%s_%s" % (self.lineno, str(self.filename).translate(MethodNode.tr_tbl))) text = "def %s(d):\n" % (funcname) + text bb.methodpool.insert_method(funcname, text, self.filename) anonfuncs = data.getVar('__BBANONFUNCS', False) or []
Signature · 1 line
1.9.1
Quoted 3 lines · Aníbal Limón
When found an anonymous function the func name is made by filename and lineno, the filename need to be converted to string before using translation because produces an error of encoding.
Could you explain a little about why we don't hit this error in general?
Cheers,
Richard
Hi Richard,
Sorry it was my mistake in my code because i'm loading a recipe file using bb.cache.Cache.loadDataFull passing an unicode filepath this causes the error but i think it need to be sanitized? to avoid this kind of problems.
Cheers,
alimon
Quoted 10 lines · Richard Purdie
Quoted 3 lines · Aníbal Limón
When found an anonymous function the func name is made by filename and lineno, the filename need to be converted to string before using translation because produces an error of encoding.
Could you explain a little about why we don't hit this error in general?
Cheers,
Richard
%s already converts the arguments to strings, last I checked. Am I missing someting here?
Quoted 33 lines · Aníbal Limón
Hi Richard,
Sorry it was my mistake in my code because i'm loading a recipe file using bb.cache.Cache.loadDataFull
passing an unicode filepath this causes the error but i think it need to be sanitized? to avoid this kind of
problems.Cheers,
alimonQuoted 6 lines · Richard Purdie
Quoted 4 lines · Aníbal Limón
When found an anonymous function the func name is made by filename and lineno, the filename need to be converted to string before using translation because produces an error of encoding.
Quoted 7 lines
Could you explain a little about why we don't hit this error in general?
Cheers,
Richard
--
_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics