diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-04-12 18:00:18 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-04-14 06:31:45 +0100 |
| commit | 6bd8367aa98e3108e9f1de9bdf809ded5dfc7413 (patch) | |
| tree | 7b0e5137c0480ef5577fd3de74f5d970c8923af9 /bitbake/lib/bb/parse/parse_py | |
| parent | 9889a0ff1af115e37ea1268f0580ef8b344c32e9 (diff) | |
| download | poky-6bd8367aa98e3108e9f1de9bdf809ded5dfc7413.tar.gz | |
bitbake: BBHandler: Handle unclosed functions correctly
A function accidentally defined as:
somefunction() {
:
}
which is unclosed due to the space at the end, would currently silently
cause breakage. Have the parser throw and error for this.
[YOCTO #15470]
(Bitbake rev: a7dce72da6be626734486808f1b731247697e638)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
| -rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index cd1c998f8f..c13e4b9755 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
| @@ -34,6 +34,7 @@ __infunc__ = [] | |||
| 34 | __inpython__ = False | 34 | __inpython__ = False |
| 35 | __body__ = [] | 35 | __body__ = [] |
| 36 | __classname__ = "" | 36 | __classname__ = "" |
| 37 | __residue__ = [] | ||
| 37 | 38 | ||
| 38 | cached_statements = {} | 39 | cached_statements = {} |
| 39 | 40 | ||
| @@ -80,7 +81,7 @@ def inherit(files, fn, lineno, d, deferred=False): | |||
| 80 | __inherit_cache = d.getVar('__inherit_cache', False) or [] | 81 | __inherit_cache = d.getVar('__inherit_cache', False) or [] |
| 81 | 82 | ||
| 82 | def get_statements(filename, absolute_filename, base_name): | 83 | def get_statements(filename, absolute_filename, base_name): |
| 83 | global cached_statements | 84 | global cached_statements, __residue__, __body__ |
| 84 | 85 | ||
| 85 | try: | 86 | try: |
| 86 | return cached_statements[absolute_filename] | 87 | return cached_statements[absolute_filename] |
| @@ -100,6 +101,11 @@ def get_statements(filename, absolute_filename, base_name): | |||
| 100 | # add a blank line to close out any python definition | 101 | # add a blank line to close out any python definition |
| 101 | feeder(lineno, "", filename, base_name, statements, eof=True) | 102 | feeder(lineno, "", filename, base_name, statements, eof=True) |
| 102 | 103 | ||
| 104 | if __residue__: | ||
| 105 | raise ParseError("Unparsed lines %s: %s" % (filename, str(__residue__)), filename, lineno) | ||
| 106 | if __body__: | ||
| 107 | raise ParseError("Unparsed lines from unclosed function %s: %s" % (filename, str(__body__)), filename, lineno) | ||
| 108 | |||
| 103 | if filename.endswith(".bbclass") or filename.endswith(".inc"): | 109 | if filename.endswith(".bbclass") or filename.endswith(".inc"): |
| 104 | cached_statements[absolute_filename] = statements | 110 | cached_statements[absolute_filename] = statements |
| 105 | return statements | 111 | return statements |
