From 633a6dfee880289143a7072b71833769d9b26972 Mon Sep 17 00:00:00 2001 From: MegaIng Date: Fri, 13 Nov 2020 12:50:05 +0100 Subject: [PATCH] Make `UnexpectedCharacters` print the repr This is an additional response to #738. I also often came across this when unexpectedly having a newline, which would previously result in the message being split up across two lines. This PR makes it easier to identify exactly which special character is causing problems. --- lark/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lark/exceptions.py b/lark/exceptions.py index 72af526..8444a65 100644 --- a/lark/exceptions.py +++ b/lark/exceptions.py @@ -130,7 +130,7 @@ class UnexpectedCharacters(LexError, UnexpectedInput): else: _s = seq[lex_pos] - message = "No terminal defined for '%s' at line %d col %d" % (_s, line, column) + message = "No terminal defined for %r at line %d col %d" % (_s, line, column) message += '\n\n' + self.get_context(seq) if allowed: message += '\nExpecting: %s\n' % allowed