Commits

Mike Bayer  committed 5214f0f

- format_exceptions will apply the encoding options
of html_error_template() to the buffered output

  • Participants
  • Parent commits d19ff8d

Comments (0)

Files changed (3)

 - fixed issue with inline format_exceptions that was producing
   blank exception pages when an inheriting template is 
   present [ticket:71]
+- format_exceptions will apply the encoding options
+  of html_error_template() to the buffered output
   
 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.FastEncodingBuffer()]
                 error_template = exceptions.html_error_template()
+                context._buffer_stack[:] = [util.FastEncodingBuffer(error_template.output_encoding, error_template.encoding_errors)]
                 context._with_template = error_template
                 error_template.render_context(context, error=error)
     else:

File test/exceptions_.py

         """)
 
         assert '<div class="sourceline">${foobar}</div>' in result_lines(l.get_template("foo.html").render())
+    
+    def test_utf8_format_exceptions(self):
+        """test that htmlentityreplace formatting is applied to exceptions reported with format_exceptions=True"""
+        
+        l = TemplateLookup(format_exceptions=True)
+
+        l.put_string("foo.html", """# -*- coding: utf-8 -*-
+${u'привет' + foobar}
+""")
+
+        assert '''<div class="highlight">2 ${u\'&#x43F;&#x440;&#x438;&#x432;&#x435;&#x442;\' + foobar}</div>''' in result_lines(l.get_template("foo.html").render())
         
 if __name__ == '__main__':
     unittest.main()