mirror of
https://gitee.com/openharmony/third_party_jinja2
synced 2025-02-18 14:40:51 +00:00
fixed bug with parameter parsing
--HG-- branch : trunk
This commit is contained in:
parent
151418ddce
commit
e9411b4189
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user