[svn] improved generic "EOF while lexing" exception message so that it tells about...
authorArmin Ronacher <armin.ronacher@active-4.com>
Tue, 29 May 2007 21:22:38 +0000 (23:22 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Tue, 29 May 2007 21:22:38 +0000 (23:22 +0200)
--HG--
branch : trunk

jinja/lexer.py

index 825722b082f3a63ff83617630bec40f644781081..d761d541bd6da52d5b10640ccd929a16d2a49d3d 100644 (file)
@@ -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: