diff options
| -rw-r--r-- | bitbake/lib/bb/data_smart.py | 7 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/data.py | 5 |
2 files changed, 11 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: |
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index e9aab577f6..a96078fa9c 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
| @@ -80,6 +80,11 @@ class DataExpansions(unittest.TestCase): | |||
| 80 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | 80 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") |
| 81 | self.assertEqual(str(val), "value_of_foo value_of_bar") | 81 | self.assertEqual(str(val), "value_of_foo value_of_bar") |
| 82 | 82 | ||
| 83 | def test_python_unexpanded(self): | ||
| 84 | self.d.setVar("bar", "${unsetvar}") | ||
| 85 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | ||
| 86 | self.assertEqual(str(val), "${@d.getVar('foo', True) + ' ${unsetvar}'}") | ||
| 87 | |||
| 83 | def test_python_snippet_syntax_error(self): | 88 | def test_python_snippet_syntax_error(self): |
| 84 | self.d.setVar("FOO", "${@foo = 5}") | 89 | self.d.setVar("FOO", "${@foo = 5}") |
| 85 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) | 90 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) |
