aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mparser.py
diff options
context:
space:
mode:
authorAaron Plattner <aaronp24@gmail.com>2017-04-06 14:10:48 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2017-04-07 00:10:48 +0300
commitc80ca384b22547147ad1515cc6527dacc4c72fe0 (patch)
tree023bd026f779f63ba3afa0c5812c86344f231e09 /mesonbuild/mparser.py
parent578c3b6b6afb353a803e96ed6f72e1cbf06cdcf9 (diff)
downloadmeson-c80ca384b22547147ad1515cc6527dacc4c72fe0.zip
meson-c80ca384b22547147ad1515cc6527dacc4c72fe0.tar.gz
meson-c80ca384b22547147ad1515cc6527dacc4c72fe0.tar.bz2
Don't crash if a meson.build file is empty (#1570)
* Don't crash if a meson.build file is empty Commit 9adef3a8e878 caused an empty meson.build file to generate a traceback: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 415, in getsym self.current = next(self.stream) StopIteration During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 298, in run app.generate() File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate intr.run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2529, in run super().run() File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run self.evaluate_codeblock(self.ast, start=1) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2237, in func_subdir self.evaluate_codeblock(codeblock) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock raise e File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock self.evaluate_statement(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement return self.function_call(cur) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call return self.funcs[func_name](node, self.flatten(posargs), kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped return f(self, node, args, kwargs) File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2233, in func_subdir codeblock = mparser.Parser(code, self.subdir).parse() File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 410, in __init__ self.getsym() File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 417, in getsym self.current = Token('eof', '', self.current.line_start, self.current.lineno, self.current.colno + self.current.bytespan[1] - self.current.bytespan[0], (0, 0), None) AttributeError: 'Parser' object has no attribute 'current'
Diffstat (limited to 'mesonbuild/mparser.py')
-rw-r--r--mesonbuild/mparser.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index 7a91539..a9f25b1 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -407,6 +407,7 @@ class Parser:
def __init__(self, code, subdir):
self.lexer = Lexer(code)
self.stream = self.lexer.lex(subdir)
+ self.current = Token('eof', '', 0, 0, 0, (0, 0), None)
self.getsym()
self.in_ternary = False