From f750daa29a2278fa341811f9761b40cfaba59d6f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 29 May 2007 23:22:38 +0200 Subject: [PATCH] [svn] improved generic "EOF while lexing" exception message so that it tells about unbalanced parentheses. --HG-- branch : trunk --- jinja/lexer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jinja/lexer.py b/jinja/lexer.py index 825722b..d761d54 100644 --- a/jinja/lexer.py +++ b/jinja/lexer.py @@ -311,10 +311,15 @@ class Lexer(object): elif data == '[': balancing_stack.append(']') elif data in ('}', ')', ']'): - if not balancing_stack or \ - balancing_stack.pop() != data: - raise TemplateSyntaxError('unexpected EOF ' - 'while lexing', + if not balancing_stack: + raise TemplateSyntaxError('unexpected "%s"' % + data, lineno, + filename) + expected_op = balancing_stack.pop() + if expected_op != data: + raise TemplateSyntaxError('unexpected "%s", ' + 'expected "%s"' % + (data, expected_op), lineno, filename) # yield items if tokens is not None: -- 2.26.2