mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
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>
This commit is contained in:
@@ -34,6 +34,7 @@ __infunc__ = []
|
|||||||
__inpython__ = False
|
__inpython__ = False
|
||||||
__body__ = []
|
__body__ = []
|
||||||
__classname__ = ""
|
__classname__ = ""
|
||||||
|
__residue__ = []
|
||||||
|
|
||||||
cached_statements = {}
|
cached_statements = {}
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ def inherit(files, fn, lineno, d, deferred=False):
|
|||||||
__inherit_cache = d.getVar('__inherit_cache', False) or []
|
__inherit_cache = d.getVar('__inherit_cache', False) or []
|
||||||
|
|
||||||
def get_statements(filename, absolute_filename, base_name):
|
def get_statements(filename, absolute_filename, base_name):
|
||||||
global cached_statements
|
global cached_statements, __residue__, __body__
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return cached_statements[absolute_filename]
|
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
|
# add a blank line to close out any python definition
|
||||||
feeder(lineno, "", filename, base_name, statements, eof=True)
|
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"):
|
if filename.endswith(".bbclass") or filename.endswith(".inc"):
|
||||||
cached_statements[absolute_filename] = statements
|
cached_statements[absolute_filename] = statements
|
||||||
return statements
|
return statements
|
||||||
|
|||||||
Reference in New Issue
Block a user