diff options
| author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-06-09 21:49:07 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2021-06-16 19:04:03 -0400 |
| commit | 3970f269fd23c148e94800ca01b6a2d76003a3a2 (patch) | |
| tree | f58a4d9bd4a0a889d8ce2fc8987fa8f3e06dcbbf | |
| parent | 6fb2f86379c224e99652748eea94a03321b9bd11 (diff) | |
| download | meson-3970f269fd23c148e94800ca01b6a2d76003a3a2.tar.gz | |
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.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/ast/printer.py b/mesonbuild/ast/printer.py index a57ba20d3..f535c2f97 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) |
