[bitbake-devel] [PATCH] data_smart/utils: Add 'd' to the context used for better_eval in python expansion

Patrick Ohly patrick.ohly at intel.com
Mon Jun 13 08:32:58 UTC 2016


On Thu, 2016-06-09 at 23:38 +0100, Richard Purdie wrote:
> If a line like:
> 
> foo=${@' '.join([d.getVar('D', True) + x for x in (' '.join([d.getVar('FILES_bash-' + p, True) or '' for p in ['lib', 'dev', 'staticdev', 'doc', 'locale', 'ptest']])).split()])}
> 
> is added to a function like do_install, it fails with Exception name 'd'
> is not defined. This is due to a change of behaviour in python 3 compared
> to python 2. Generator expressions, dict comprehensions  and set comprehensions
> are executed in a new scope but list comprehensions in python 2.x are not. In
> python 3 they all use a new scope.
> 
> To allow these kinds of expressions to work, the easiest approach is
> to add 'd' to the global context. To do this, an extra optional parameter
> is added to better_eval and we use that to add 'd'.
> 
> Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

I'm building Ostro OS with this patch, which is where the scoping
problem was first found. Seems to work for me, so please include it.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.






More information about the bitbake-devel mailing list