self.visit(node.test)
real_identifiers = self.identifiers
- old_names = real_identifiers.declared | \
- real_identifiers.declared_locally | \
+ old_names = real_identifiers.declared_locally | \
real_identifiers.declared_parameter
def inner_visit(nodes):
# the differences between the two branches are also pulled as
# undeclared variables
- real_identifiers.undeclared.update(body.symmetric_difference(else_))
+ real_identifiers.undeclared.update(body.symmetric_difference(else_) -
+ real_identifiers.declared)
# remember those that are declared.
real_identifiers.declared_locally.update(body | else_)
''')
assert t.render(a=0, b=False, c=42, d=42.0) == '1111C'
+ def test_stacked_locals_scoping_bug_twoframe(self):
+ t = Template('''
+ {% set x = 1 %}
+ {% for item in foo %}
+ {% if item == 1 %}
+ {% set x = 2 %}
+ {% endif %}
+ {% endfor %}
+ {{ x }}
+ ''')
+ rv = t.render(foo=[1]).strip()
+ assert rv == u'1'
+
def test_call_with_args(self):
t = Template("""{% macro dump_users(users) -%}
<ul>