summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-21 14:05:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-22 12:01:24 +0000
commitcf9cb65eeccf26310177e4013848ebc609dfdb31 (patch)
tree77ef4544619bbb1b5e968c3147d4f85c084db528 /bitbake/lib/bb/data_smart.py
parentb80219eac1695044554c18994124ae32c04642c6 (diff)
downloadpoky-cf9cb65eeccf26310177e4013848ebc609dfdb31.tar.gz
bitbake: data_smart: Don't show exceptions for EOL literals
If variables are unset, the code simply doesn't expand them, there aren't errors. If the code is a python expression, this can get a bit messy, see the attached test case. The python expansion code sees the } of the unexpanded value rather than the close of the python expression and then raises a SyntaxError exception. Ideally, we'd update the code to match pairs of brackets. I don't know how to do that with the current regex and this is unfortunately a performance sensitive piece of code. We also run the risk of breaking existing code in OE-Core where there are "{" characters but not "}" to close them (PKGE and PE). Rather than raising the exception, matching the existing "just return the expression" behaviour seems more consistent with the standard variable behaviour. This addresses an issue found in the recent image.bbclass code where there are some variables we choose not to expand (TMPDIR/DATETIME). This patch also adds a test case for this behaviour. It wouldn't preclude improved bracket matching code in the future either. (Bitbake rev: d80d39e73223a50fda0090784303d2c57167bb4c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index ca5774b26b..66cb84564e 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -384,7 +384,12 @@ class DataSmart(MutableMapping):
384 olds = s 384 olds = s
385 try: 385 try:
386 s = __expand_var_regexp__.sub(varparse.var_sub, s) 386 s = __expand_var_regexp__.sub(varparse.var_sub, s)
387 s = __expand_python_regexp__.sub(varparse.python_sub, s) 387 try:
388 s = __expand_python_regexp__.sub(varparse.python_sub, s)
389 except SyntaxError as e:
390 # Likely unmatched brackets, just don't expand the expression
391 if e.msg != "EOL while scanning string literal":
392 raise
388 if s == olds: 393 if s == olds:
389 break 394 break
390 except ExpansionError: 395 except ExpansionError: