summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2010-07-08 14:22:07 +0000
committerFred Drake <fdrake@acm.org>2010-07-08 14:22:07 +0000
commit90179881d5b1da56a1b3cd0722cb68420b1dec1f (patch)
tree6988e6ad52d60380d3025a833e6840d5b7c500fb
parent8689f748a48ef25cf21ef5019affec45d20c334c (diff)
downloadzope-pagetemplate-90179881d5b1da56a1b3cd0722cb68420b1dec1f.tar.gz
make the PTRuntimeError exception message consistent across Python versions
-rw-r--r--CHANGES.txt5
-rw-r--r--src/zope/pagetemplate/pagetemplate.py3
-rw-r--r--src/zope/pagetemplate/tests/test_basictemplate.py18
3 files changed, 22 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 1e044bc..afae4ba 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,9 +2,12 @@
CHANGES
=======
-3.5.2 (unreleased)
+3.5.2 (2010-07-08)
------------------
+- Fixed PTRuntimeError exception messages to be consistent across Python
+ versions, and compatibile with the output under Python 2.4. (More
+ readable than the previous output under Python 2.6 as well.)
3.5.1 (2010-04-30)
------------------
diff --git a/src/zope/pagetemplate/pagetemplate.py b/src/zope/pagetemplate/pagetemplate.py
index 03a2878..f9ed040 100644
--- a/src/zope/pagetemplate/pagetemplate.py
+++ b/src/zope/pagetemplate/pagetemplate.py
@@ -189,8 +189,9 @@ class PageTemplate(object):
parser.parseString(self._text)
self._v_program, self._v_macros = parser.getCode()
except:
+ etype, e = sys.exc_info()[:2]
self._v_errors = ["Compilation failed",
- "%s: %s" % sys.exc_info()[:2]]
+ "%s.%s: %s" % (etype.__module__, etype.__name__, e)]
self._v_cooked = 1
diff --git a/src/zope/pagetemplate/tests/test_basictemplate.py b/src/zope/pagetemplate/tests/test_basictemplate.py
index f5cb5df..d77f665 100644
--- a/src/zope/pagetemplate/tests/test_basictemplate.py
+++ b/src/zope/pagetemplate/tests/test_basictemplate.py
@@ -16,12 +16,13 @@
import unittest
from zope.pagetemplate.tests import util
-from zope.pagetemplate.pagetemplate import PageTemplate
+import zope.pagetemplate.pagetemplate
+
class BasicTemplateTests(unittest.TestCase):
def setUp(self):
- self.t = PageTemplate()
+ self.t = zope.pagetemplate.pagetemplate.PageTemplate()
def test_if_in_var(self):
# DTML test 1: if, in, and var:
@@ -59,6 +60,19 @@ class BasicTemplateTests(unittest.TestCase):
expect = util.read_output('dtml1b.html')
util.check_xml(expect, o)
+ def test_pt_runtime_error(self):
+ self.t.write("<tal:block define='a string:foo'>xyz")
+ try:
+ self.t.pt_render({})
+ except zope.pagetemplate.pagetemplate.PTRuntimeError, e:
+ self.assertEquals(
+ str(e),
+ "['Compilation failed', 'zope.tal.taldefs.TALError:"
+ " TAL attributes on <tal:block> require explicit"
+ " </tal:block>, at line 1, column 1']")
+ else:
+ self.fail("expected PTRuntimeError")
+
def test_batches_and_formatting(self):
# DTML test 3: batches and formatting:
pass # for unittest