summaryrefslogtreecommitdiff
path: root/jinja2/optimizer.py
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2008-04-25 23:44:14 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2008-04-25 23:44:14 +0200
commit0611e49bb983fcefc3defd360c962f18ddb8b84f (patch)
tree4d66a27954638f3bf95bfa333417c9b4f41eb282 /jinja2/optimizer.py
parent6ce170c496157ca994ceb90790067a6b845274a3 (diff)
downloadjinja2-0611e49bb983fcefc3defd360c962f18ddb8b84f.tar.gz
revamped jinja2 import system. the behavior is less confusing now, but it's not backwards compatible. I like it though ;)
--HG-- branch : trunk
Diffstat (limited to 'jinja2/optimizer.py')
-rw-r--r--jinja2/optimizer.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/jinja2/optimizer.py b/jinja2/optimizer.py
index 4d7b9f5..c432b3b 100644
--- a/jinja2/optimizer.py
+++ b/jinja2/optimizer.py
@@ -173,6 +173,17 @@ class Optimizer(NodeTransformer):
return node
return result
+ def visit_Import(self, node, context):
+ rv = self.generic_visit(node, context)
+ context.undef(node.target)
+ return rv
+
+ def visit_FromImport(self, node, context):
+ rv = self.generic_visit(node, context)
+ for name in node.names:
+ context.undef(name)
+ return rv
+
def fold(self, node, context):
"""Do constant folding."""
node = self.generic_visit(node, context)