[bitbake-devel,4/6] bitbake: data_smart: fix filename for compile()

Submitted by Robert Yang on Nov. 14, 2018, 9:46 a.m. | Patch ID: 156280

Details

Message ID e60e633f668e5bb1c9fb0fa14f84577504b38d9a.1542188647.git.liezhi.yang@windriver.com
State New
Headers show

Commit Message

Robert Yang Nov. 14, 2018, 9:46 a.m.
Fixed:
Add the following two lines to conf/local.conf:
FOO = "${@foo = 5}"
HOSTTOOLS += "${FOO}"

* Before the patch
  $ bitbake -p
  Check the first lines of bitbake bitbake-cookerdaemon.log
  [snip]
  File "/buildarea1/lyang1/poky/bitbake/lib/bb/data_smart.py", line 125, in python_sub
    codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
  File "FOO", line 1
  [snip]

  There isn't a file named 'FOO', but a variable name.

* After the patch
  $ bitbake -p
  [snip]
  File "/buildarea1/lyang1/poky/bitbake/lib/bb/data_smart.py", line 129, in python_sub
    codeobj = compile(code.strip(), varname, "eval")
  File "Var <FOO>", line 1
    foo = 5

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 bitbake/lib/bb/data_smart.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index efa5a79..67af380 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -122,7 +122,11 @@  class VariableParse:
                 connector = self.d["_remote_data"]
                 return connector.expandPythonRef(self.varname, code, self.d)
 
-            codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
+            if self.varname:
+                varname = 'Var <%s>' % self.varname
+            else:
+                varname = '<expansion>'
+            codeobj = compile(code.strip(), varname, "eval")
 
             parser = bb.codeparser.PythonParser(self.varname, logger)
             parser.parse_python(code)