From: Armin Ronacher Date: Tue, 29 May 2007 21:22:38 +0000 (+0200) Subject: [svn] improved generic "EOF while lexing" exception message so that it tells about... X-Git-Tag: 2.0rc1~311 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f750daa29a2278fa341811f9761b40cfaba59d6f;p=jinja2.git [svn] improved generic "EOF while lexing" exception message so that it tells about unbalanced parentheses. --HG-- branch : trunk --- 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: