From: Armin Ronacher Date: Thu, 15 May 2008 14:22:07 +0000 (+0200) Subject: fixed bug with parameter parsing X-Git-Tag: 2.0rc1~56 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e9411b41890c0882236918297fb2e77a3bf60cd1;p=jinja2.git fixed bug with parameter parsing --HG-- branch : trunk --- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 7a2ea4c..30054e7 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -254,8 +254,10 @@ class FrameIdentifierVisitor(NodeVisitor): def visit_Name(self, node): """All assignments to names go through this function.""" - if node.ctx in ('store', 'param'): + if node.ctx == 'store': self.identifiers.declared_locally.add(node.name) + elif node.ctx == 'param': + self.identifiers.declared_parameter.add(node.name) elif node.ctx == 'load' and not \ self.identifiers.is_declared(node.name, self.hard_scope): self.identifiers.undeclared.add(node.name) @@ -271,8 +273,7 @@ class FrameIdentifierVisitor(NodeVisitor): if isinstance(node.arg, nodes.Const) and \ isinstance(node.arg.value, basestring) and \ ((isinstance(node.node, nodes.Name) and - node.node.name not in (self.identifiers.declared_locally | - self.identifiers.declared_parameter)) or \ + node.node.name not in (self.identifiers.declared_locally)) or node.node in self.identifiers.static_subscribes): if node in self.identifiers.static_subscribes: self.identifiers.static_subscribes[node] += 1 diff --git a/jinja2/parser.py b/jinja2/parser.py index f2a129c..19ee166 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -220,6 +220,7 @@ class Parser(object): if args: self.stream.expect('comma') arg = self.parse_assign_target(name_only=True) + arg.set_ctx('param') if self.stream.skip_if('assign'): defaults.append(self.parse_expression()) args.append(arg) diff --git a/jinja2/runtime.py b/jinja2/runtime.py index cbe7115..b5f0783 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -121,8 +121,7 @@ class Context(object): return dict(self.parent, **self.vars) def _all(meth): - def proxy(self): - return getattr(self.get_all(), meth)() + proxy = lambda self: getattr(self.get_all(), meth)() proxy.__doc__ = getattr(dict, meth).__doc__ proxy.__name__ = meth return proxy