aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-06-09 21:49:07 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-06-16 19:04:03 -0400
commit3970f269fd23c148e94800ca01b6a2d76003a3a2 (patch)
treef58a4d9bd4a0a889d8ce2fc8987fa8f3e06dcbbf
parent6fb2f86379c224e99652748eea94a03321b9bd11 (diff)
downloadmeson-3970f269fd23c148e94800ca01b6a2d76003a3a2.zip
meson-3970f269fd23c148e94800ca01b6a2d76003a3a2.tar.gz
meson-3970f269fd23c148e94800ca01b6a2d76003a3a2.tar.bz2
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.
-rw-r--r--mesonbuild/ast/printer.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/ast/printer.py b/mesonbuild/ast/printer.py
index a57ba20..f535c2f 100644
--- a/mesonbuild/ast/printer.py
+++ b/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)