summaryrefslogtreecommitdiffstats
path: root/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:17 +0000
commitd80d39e73223a50fda0090784303d2c57167bb4c (patch)
tree4f8441239cd38235205f69c262a71d98b69beb31 /lib/bb/data_smart.py
parent4eb15605a1436631b3673bdba39af14bcb3a0e6d (diff)
downloadbitbake-d80d39e73223a50fda0090784303d2c57167bb4c.tar.gz
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. 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 'lib/bb/data_smart.py')
-rw-r--r--lib/bb/data_smart.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index ca5774b26..66cb84564 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -384,7 +384,12 @@ class DataSmart(MutableMapping):
olds = s
try:
s = __expand_var_regexp__.sub(varparse.var_sub, s)
- s = __expand_python_regexp__.sub(varparse.python_sub, s)
+ try:
+ s = __expand_python_regexp__.sub(varparse.python_sub, s)
+ except SyntaxError as e:
+ # Likely unmatched brackets, just don't expand the expression
+ if e.msg != "EOL while scanning string literal":
+ raise
if s == olds:
break
except ExpansionError: