summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-04-12 18:00:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-04-14 06:31:45 +0100
commit6bd8367aa98e3108e9f1de9bdf809ded5dfc7413 (patch)
tree7b0e5137c0480ef5577fd3de74f5d970c8923af9
parent9889a0ff1af115e37ea1268f0580ef8b344c32e9 (diff)
downloadpoky-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>
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py8
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
38cached_statements = {} 39cached_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
82def get_statements(filename, absolute_filename, base_name): 83def 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