# HG changeset patch # User cmlenz # Date 1151963456 0 # Node ID 28ddb79414b26b2c3f06be32c37cbe61c4999593 # Parent 686059a8a32bbaaaeb0768232ad15f2d6781b599 Catch `KeyError` exception when trying attribute access in expression evaluation. diff --git a/markup/eval.py b/markup/eval.py --- a/markup/eval.py +++ b/markup/eval.py @@ -125,7 +125,7 @@ return getattr(obj, node.attrname) try: return obj[node.attrname] - except TypeError: + except (KeyError, TypeError): return None def _visit_slice(self, node, data): @@ -265,7 +265,7 @@ return getattr(obj, node.attr) try: return obj[node.attr] - except TypeError: + except (KeyError, TypeError): return None def _visit_call(self, node, data):