aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--lib/mako/codegen.py2
2 files changed, 2 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 5403c80..960217e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,7 @@ By setting to [], expressions are passed through raw.
- added "imports" argument to Template, TemplateLookup. so you can predefine a list of
import statements at the top of the template. can be used in conjunction with
default_filters.
+- small fix to local variable propigation for locals that are conditionally declared
0.1.1
- buffet plugin supports string-based templates, allows ToscaWidgets to work [ticket:8]
diff --git a/lib/mako/codegen.py b/lib/mako/codegen.py
index ba83f1b..a18dffc 100644
--- a/lib/mako/codegen.py
+++ b/lib/mako/codegen.py
@@ -452,7 +452,7 @@ class _GenerateRenderMethod(object):
if not self.in_def and len(self.identifiers.locally_assigned) > 0:
# if we are the "template" def, fudge locally declared/modified variables into the "__locals" dictionary,
# which is used for def calls within the same template, to simulate "enclosing scope"
- self.printer.writeline('__locals.update(dict([(k, locals()[k]) for k in [%s]]))' % ','.join([repr(x) for x in node.declared_identifiers()]))
+ self.printer.writeline('__locals.update(dict([(k, locals()[k]) for k in [%s] if k in locals()]))' % ','.join([repr(x) for x in node.declared_identifiers()]))
def visitIncludeTag(self, node):
self.write_source_comment(node)