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:
parent
6fb2f86379
commit
3970f269fd
|
@ -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…
Reference in New Issue