Fix assert(not true) raising backtrace

When no message is provided to assert(), it uses the ast printer to show
the condition that failed. In this case the 'not' is the first string
appended to the result, self.result[-1] would raise range error.
pull/8892/head
Xavier Claessens 4 years ago committed by Xavier Claessens
parent 6fb2f86379
commit 3970f269fd
  1. 2
      mesonbuild/ast/printer.py

@ -48,7 +48,7 @@ class AstPrinter(AstVisitor):
self.is_newline = False
def append_padded(self, data: str, node: mparser.BaseNode) -> None:
if self.result[-1] not in [' ', '\n']:
if self.result and self.result[-1] not in [' ', '\n']:
data = ' ' + data
self.append(data + ' ', node)

Loading…
Cancel
Save