diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-17 16:55:52 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-17 16:55:52 -0400 |
commit | 68c722954981c3eae3929ceb1b62d7bff7b7ba96 (patch) | |
tree | 7e88c6c42cb414b853307a24a270b9aac69ba842 | |
parent | 6cf6461d778243d8a8986c658eb2246e5939bdce (diff) | |
download | mako-68c722954981c3eae3929ceb1b62d7bff7b7ba96.tar.gz |
- Fixed error formatting when a stacktrace
line contains no line number, as in when
inside an eval/exec-generated function.
[ticket:132]
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | mako/exceptions.py | 2 | ||||
-rw-r--r-- | test/test_exceptions.py | 10 |
3 files changed, 17 insertions, 0 deletions
@@ -7,6 +7,11 @@ - Fixed broken @property decorator on template.last_modified + +- Fixed error formatting when a stacktrace + line contains no line number, as in when + inside an eval/exec-generated function. + [ticket:132] 0.3.2 - Calling a def from the top, via diff --git a/mako/exceptions.py b/mako/exceptions.py index c0d7fd9..0c1f844 100644 --- a/mako/exceptions.py +++ b/mako/exceptions.py @@ -152,6 +152,8 @@ class RichTraceback(object): rawrecords = traceback.extract_tb(trcback) new_trcback = [] for filename, lineno, function, line in rawrecords: + if not line: + line = '' try: (line_map, template_lines) = mods[filename] except KeyError: diff --git a/test/test_exceptions.py b/test/test_exceptions.py index 22f879d..ab2f8e4 100644 --- a/test/test_exceptions.py +++ b/test/test_exceptions.py @@ -73,6 +73,16 @@ ${u'привет'} assert False, ("This function should trigger a CompileException, " "but didn't") + def test_format_closures(self): + try: + exec "def foo():"\ + " raise RuntimeError('test')"\ + in locals() + foo() + except: + html_error = exceptions.html_error_template().render() + assert "RuntimeError: test" in html_error + def test_py_utf8_html_error_template(self): try: foo = u'日本' |