removed loop.parent. If this variable is wanted you can get it by doing something...
authorArmin Ronacher <armin.ronacher@active-4.com>
Fri, 18 Apr 2008 08:32:14 +0000 (10:32 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Fri, 18 Apr 2008 08:32:14 +0000 (10:32 +0200)
--HG--
branch : trunk

jinja2/compiler.py
jinja2/optimizer.py
jinja2/runtime.py

index 4b093ff52e61f47002f0e1b9d1966aa736f6468b..b7aae4608b10b46bb3cfee29634b61999bbaf236 100644 (file)
@@ -656,8 +656,6 @@ class CodeGenerator(NodeVisitor):
         else:
             self.visit(node.iter, loop_frame)
 
-        if 'loop' in aliases:
-            self.write(', ' + aliases['loop'])
         self.write(extended_loop and '):' or ':')
 
         # tests in not extended loops become a continue
index fd5922c645814a25e0c9bef26f4635785fe06006..6b13aec25347accf7c9889860a46b70573f075ad 100644 (file)
@@ -145,7 +145,6 @@ class Optimizer(NodeTransformer):
         except (nodes.Impossible, TypeError):
             return fallback
 
-        parent = context.get('loop')
         context.push()
         result = []
         iterated = False
@@ -181,7 +180,7 @@ class Optimizer(NodeTransformer):
 
         try:
             try:
-                for item, loop in LoopContext(iterable, parent, True):
+                for item, loop in LoopContext(iterable, True):
                     context['loop'] = loop.make_static()
                     assign(node.target, item)
                     result.extend(self.visit(n.copy(), context)
index 8e407c9a9b7f22fe1b06cda4c424d561d4b18df9..1f1d7bd7bb68c41cf6830277f3fe4ad916878dc0 100644 (file)
@@ -152,21 +152,17 @@ class LoopContextBase(object):
 class LoopContext(LoopContextBase):
     """A loop context for dynamic iteration."""
 
-    def __init__(self, iterable, parent=None, enforce_length=False):
+    def __init__(self, iterable, enforce_length=False):
         self._iterable = iterable
         self._next = iter(iterable).next
         self._length = None
         self.index0 = -1
-        self.parent = parent
         if enforce_length:
             len(self)
 
     def make_static(self):
         """Return a static loop context for the optimizer."""
-        parent = None
-        if self.parent is not None:
-            parent = self.parent.make_static()
-        return StaticLoopContext(self.index0, self.length, parent)
+        return StaticLoopContext(self.index0, self.length)
 
     def __iter__(self):
         return self
@@ -197,17 +193,15 @@ class StaticLoopContext(LoopContextBase):
     loop object is accessed in a non static way (eg: becomes part of a
     function call)."""
 
-    def __init__(self, index0, length, parent):
+    def __init__(self, index0, length):
         self.index0 = index0
-        self.parent = parent
         self.length = length
 
     def __repr__(self):
         """The repr is used by the optimizer to dump the object."""
-        return 'StaticLoopContext(%r, %r, %r)' % (
+        return 'StaticLoopContext(%r, %r)' % (
             self.index0,
-            self.length,
-            self.parent
+            self.length
         )
 
     def make_static(self):