From 808dde1450ace1a929d2f6a289bd3e6293c84bad Mon Sep 17 00:00:00 2001 From: Mike Bayer <mike_mp@zzzcomputing.com> Date: Tue, 22 Jun 2010 11:57:18 -0400 Subject: [PATCH] - Fixed call to "unicode.strip" in exceptions.text_error_template which is not Py3k compatible. [ticket:137] --- CHANGES | 6 +++++- mako/__init__.py | 2 +- mako/exceptions.py | 2 +- test/test_exceptions.py | 20 ++++++++++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index d9fd1a4..6ff3824 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ - +0.3.4 +- Fixed call to "unicode.strip" in + exceptions.text_error_template which + is not Py3k compatible. [ticket:137] + 0.3.3 - Added conditional to RichTraceback such that if no traceback is passed diff --git a/mako/__init__.py b/mako/__init__.py index 336d7a8..2d13593 100644 --- a/mako/__init__.py +++ b/mako/__init__.py @@ -5,5 +5,5 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php -__version__ = '0.3.3' +__version__ = '0.3.4' diff --git a/mako/exceptions.py b/mako/exceptions.py index 6e95751..b9df87e 100644 --- a/mako/exceptions.py +++ b/mako/exceptions.py @@ -247,7 +247,7 @@ def text_error_template(lookup=None): Traceback (most recent call last): % for (filename, lineno, function, line) in tback.traceback: File "${filename}", line ${lineno}, in ${function or '?'} - ${line | unicode.strip} + ${line | trim} % endfor ${tback.errorname}: ${tback.message} """) diff --git a/test/test_exceptions.py b/test/test_exceptions.py index 13be3a8..c136725 100644 --- a/test/test_exceptions.py +++ b/test/test_exceptions.py @@ -17,12 +17,12 @@ class ExceptionsTest(TemplateTest): try: template = Template(code) template.render_unicode() + assert False except exceptions.CompileException, ce: html_error = exceptions.html_error_template().render_unicode() assert ("CompileException: Fragment 'i = 0' is not a partial " "control statement") in html_error assert '<style>' in html_error - assert '</style>' in html_error html_error_stripped = html_error.strip() assert html_error_stripped.startswith('<html>') assert html_error_stripped.endswith('</html>') @@ -30,18 +30,30 @@ class ExceptionsTest(TemplateTest): not_full = exceptions.html_error_template().\ render_unicode(full=False) assert '<html>' not in not_full - assert '</html>' not in not_full assert '<style>' in not_full - assert '</style>' in not_full no_css = exceptions.html_error_template().\ render_unicode(css=False) assert '<style>' not in no_css - assert '</style>' not in no_css else: assert False, ("This function should trigger a CompileException, " "but didn't") + def test_text_error_template(self): + code = """ +% i = 0 +""" + try: + template = Template(code) + template.render_unicode() + assert False + except exceptions.CompileException, ce: + text_error = exceptions.text_error_template().render_unicode() + assert 'Traceback (most recent call last):' in text_error + assert ("CompileException: Fragment 'i = 0' is not a partial " + "control statement") in text_error + + def test_utf8_html_error_template(self): """test the html_error_template with a Template containing utf8 chars""" -- GitLab