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.
This commit is contained in:
Xavier Claessens 2021-06-09 21:49:07 -04:00 committed by Xavier Claessens
parent 6fb2f86379
commit 3970f269fd
1 changed files with 1 additions and 1 deletions

View File

@ -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)