summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-17 16:55:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-17 16:55:52 -0400
commit68c722954981c3eae3929ceb1b62d7bff7b7ba96 (patch)
tree7e88c6c42cb414b853307a24a270b9aac69ba842
parent6cf6461d778243d8a8986c658eb2246e5939bdce (diff)
downloadmako-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--CHANGES5
-rw-r--r--mako/exceptions.py2
-rw-r--r--test/test_exceptions.py10
3 files changed, 17 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 9af7147..0668542 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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'日本'