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-12 18:03:21 +0100 |
commit | 831aa45a2c3521a8346d9c7227cc3ab65e108de4 (patch) | |
tree | fdcc26f334ad55de278da4368af88d2c06bc2ce0 | |
parent | b34fdd96569cd62af99ca163bb994a3329bdc919 (diff) | |
download | bitbake-contrib-831aa45a2c3521a8346d9c7227cc3ab65e108de4.tar.gz |
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]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/parse/parse_py/BBHandler.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/bb/parse/parse_py/BBHandler.py b/lib/bb/parse/parse_py/BBHandler.py index cd1c998f8..c13e4b975 100644 --- a/lib/bb/parse/parse_py/BBHandler.py +++ b/lib/bb/parse/parse_py/BBHandler.py @@ -34,6 +34,7 @@ __infunc__ = [] __inpython__ = False __body__ = [] __classname__ = "" +__residue__ = [] cached_statements = {} @@ -80,7 +81,7 @@ def inherit(files, fn, lineno, d, deferred=False): __inherit_cache = d.getVar('__inherit_cache', False) or [] def get_statements(filename, absolute_filename, base_name): - global cached_statements + global cached_statements, __residue__, __body__ try: return cached_statements[absolute_filename] @@ -100,6 +101,11 @@ def get_statements(filename, absolute_filename, base_name): # add a blank line to close out any python definition feeder(lineno, "", filename, base_name, statements, eof=True) + if __residue__: + raise ParseError("Unparsed lines %s: %s" % (filename, str(__residue__)), filename, lineno) + if __body__: + raise ParseError("Unparsed lines from unclosed function %s: %s" % (filename, str(__body__)), filename, lineno) + if filename.endswith(".bbclass") or filename.endswith(".inc"): cached_statements[absolute_filename] = statements return statements |