From: Armin Ronacher Date: Thu, 5 Feb 2009 22:13:15 +0000 (+0100) Subject: Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible. X-Git-Tag: 2.2~43 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ee2d3c43fa2659e32926dfc438e6f281c86ed1a2;p=jinja2.git Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible. --HG-- branch : trunk --- diff --git a/CHANGES b/CHANGES index bf7853e..edbdb0e 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ Version 2.2 required parentheses (`not (foo in bar)`) which was odd. - Fixed a bug that caused syntax errors when defining macros or using the `{% call %}` tag inside loops. +- Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible. Version 2.1.1 ------------- diff --git a/jinja2/parser.py b/jinja2/parser.py index b6e23df..d3eb8c4 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -602,7 +602,7 @@ class Parser(object): if len(args) == 1: arg = args[0] else: - arg = nodes.Tuple(args, self.lineno, self.filename) + arg = nodes.Tuple(args, 'load', lineno=token.lineno) return nodes.Getitem(node, arg, 'load', lineno=token.lineno) self.fail('expected subscript expression', self.lineno) diff --git a/tests/test_syntax.py b/tests/test_syntax.py index 2a8e46f..5e9e804 100644 --- a/tests/test_syntax.py +++ b/tests/test_syntax.py @@ -195,3 +195,11 @@ def test_notin(env): bar = xrange(100) tmpl = env.from_string('''{{ not 42 in bar }}''') assert tmpl.render(bar=bar) == unicode(not 42 in bar) + + +def test_implicit_subscribed_tuple(env): + class Foo(object): + def __getitem__(self, x): + return x + t = env.from_string('{{ foo[1, 2] }}') + assert t.render(foo=Foo()) == u'(1, 2)'