Commits

Mike Bayer  committed d19ff8d

- fixed issue with inline format_exceptions that was producing
blank exception pages when an inheriting template is
present [ticket:71]

  • Participants
  • Parent commits 08b7b7c

Comments (0)

Files changed (3)

 - fixed lexer exceptions not cleaning up temporary files, which
   could lead to a maximum number of file descriptors used in the
   process [ticket:69]
+- fixed issue with inline format_exceptions that was producing
+  blank exception pages when an inheriting template is 
+  present [ticket:71]
   
 0.1.10
 - fixed propagation of 'caller' such that nested %def calls

File lib/mako/runtime.py

                 if not result:
                     raise error
             else:
-                context._buffer_stack = [util.StringIO()]
+                context._buffer_stack[:] = [util.FastEncodingBuffer()]
                 error_template = exceptions.html_error_template()
                 context._with_template = error_template
                 error_template.render_context(context, error=error)

File test/exceptions_.py

 
 from mako import exceptions
 from mako.template import Template
+from mako.lookup import TemplateLookup
+from util import result_lines
 
 class ExceptionsTest(unittest.TestCase):
     def test_html_error_template(self):
         else:
             assert False, ("This function should trigger a CompileException, "
                            "but didn't")
-            
+    
+    def test_format_exceptions(self):
+        l = TemplateLookup(format_exceptions=True)
+
+        l.put_string("foo.html", """
+<%inherit file="base.html"/>
+${foobar}
+        """)
+
+        l.put_string("base.html", """
+        ${self.body()}
+        """)
+
+        assert '<div class="sourceline">${foobar}</div>' in result_lines(l.get_template("foo.html").render())
+        
 if __name__ == '__main__':
     unittest.main()