- Fixed namespace.__getattr__() to raise AttributeError on attribute not found instead of RuntimeError. [ticket:104]
diff --git a/CHANGES b/CHANGES index c81d5bc..c58b10a 100644 --- a/CHANGES +++ b/CHANGES
@@ -6,9 +6,14 @@ other uses there may be (but there may be). Examples are in the "filtering" docs. +- Fixed namespace.__getattr__() to raise + AttributeError on attribute not found + instead of RuntimeError. [ticket:104] + - Added last_modified accessor to Template, returns the time.time() when the module was created. [ticket:97] + - Fixed lexing support for whitespace around '=' sign in defs. [ticket:102]
diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py index f4ef503..62b504a 100644 --- a/lib/mako/runtime.py +++ b/lib/mako/runtime.py
@@ -260,7 +260,7 @@ if self.inherits is not None: return getattr(self.inherits, key) - raise exceptions.RuntimeException("Namespace '%s' has no member '%s'" % (self.name, key)) + raise AttributeError("Namespace '%s' has no member '%s'" % (self.name, key)) def supports_caller(func): """apply a caller_stack compatibility decorator to a plain Python function."""
diff --git a/test/namespace.py b/test/namespace.py index 1515809..a3cabd7 100644 --- a/test/namespace.py +++ b/test/namespace.py
@@ -371,7 +371,22 @@ "foo lala", ] - + def test_attr_raise(self): + l = lookup.TemplateLookup() + + l.put_string("foo.html", """ + <%def name="foo()"> + </%def> + """) + + l.put_string("bar.html", """ + <%namespace name="foo" file="foo.html"/> + + ${foo.notfoo()} + """) + + self.assertRaises(AttributeError, l.get_template("bar.html").render) + def test_custom_tag_1(self): template = Template("""