fixed macro return value (for autoescaping) and avoided double free in BaseContext_clear
authorArmin Ronacher <armin.ronacher@active-4.com>
Tue, 6 Nov 2007 18:29:09 +0000 (19:29 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Tue, 6 Nov 2007 18:29:09 +0000 (19:29 +0100)
--HG--
branch : trunk

jinja/_speedups.c
jinja/datastructure.py
jinja/translators/python.py
jinja/utils.py

index eba129b0a1e55dbaba2dcb37181e17ed7466ffe2..198b7a0dc23dc81ce9cd38149d868472fe8bb4fb 100644 (file)
@@ -70,6 +70,7 @@ BaseContext_clear(BaseContext *self)
                current = tmp->prev;
                PyMem_Free(tmp);
        }
+       self->current = NULL;
        return 0;
 }
 
index 56e07b3eb408258af2acf00a025787b3c6104207..8ad6f5a66bdb94bc26131f7d1095c686bd2801a0 100644 (file)
@@ -8,7 +8,6 @@
     :copyright: 2007 by Armin Ronacher.
     :license: BSD, see LICENSE for more details.
 """
-
 from jinja.exceptions import TemplateSyntaxError, TemplateRuntimeError
 
 _missing = object()
index 04b9aed774ee00af6a2462971f46ab6ebc1b7535..f07fdc36e12adfa60cba84619f82e0c484c1be32 100644 (file)
@@ -738,7 +738,7 @@ class PythonTranslator(Translator):
         write('context.pop()')
         write('if 0: yield None')
         self.indention -= 1
-        buf.append(self.indent('context[%r] = buffereater(macro)' %
+        buf.append(self.indent('context[%r] = buffereater(macro, True)' %
                                node.name))
         self.used_utils.add('buffereater')
 
index 94619909aabffbbc8628b2d2e45102920359da37..7fe5d2ebf656e8623dbf35b38548ad537a906189 100644 (file)
@@ -17,6 +17,7 @@ import string
 from types import MethodType, FunctionType
 from jinja import nodes
 from jinja.exceptions import SecurityException, TemplateNotFound
+from jinja.datastructure import TemplateData
 
 # the python2.4 version of deque is missing the remove method
 # because a for loop with a lookup for the missing value written
@@ -363,14 +364,17 @@ def pformat(obj, verbose=False):
         return pformat(obj)
 
 
-def buffereater(f):
+def buffereater(f, template_data=False):
     """
     Used by the python translator to capture output of substreams.
     (macros, filter sections etc)
     """
     def wrapped(*a, **kw):
         __traceback_hide__ = True
-        return capture_generator(f(*a, **kw))
+        rv = capture_generator(f(*a, **kw))
+        if template_data:
+            rv = TemplateData(rv)
+        return rv
     return wrapped