From bbbe062c7b5f12758e83abaf6db3f46153643362 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 19 May 2008 00:23:37 +0200 Subject: [PATCH] fixed an embarrassing mistake in the documentation --HG-- branch : trunk --- docs/intro.rst | 2 +- jinja2/environment.py | 2 +- jinja2/runtime.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/intro.rst b/docs/intro.rst index e1d07eb..ffb6839 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -72,7 +72,7 @@ Installing the development version ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Install `mercurial`_ -2. ``svn co http://dev.pocoo.org/hg/jinja2-main jinja2`` +2. ``hg clone http://dev.pocoo.org/hg/jinja2-main jinja2`` 3. ``cd jinja2`` 4. ``ln -s jinja2 /usr/lib/python2.X/site-packages`` diff --git a/jinja2/environment.py b/jinja2/environment.py index 37ebdc6..f8826e6 100644 --- a/jinja2/environment.py +++ b/jinja2/environment.py @@ -604,7 +604,7 @@ class TemplateModule(object): self.__name__ = template.name __html__ = lambda x: Markup(concat(x._body_stream)) - __unicode__ = lambda x: unicode(concat(x._body_stream)) + __unicode__ = lambda x: concat(x._body_stream) def __str__(self): return unicode(self).encode('utf-8') diff --git a/jinja2/runtime.py b/jinja2/runtime.py index 085120b..76eae80 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -140,10 +140,13 @@ class Context(object): return name in self.vars or name in self.parent def __getitem__(self, key): - """Lookup a variable or raise `KeyError`.""" - if key in self.vars: - return self.vars[key] - return self.parent[key] + """Lookup a variable or raise `KeyError` if the variable is + undefined. + """ + item = self.resolve(key) + if isinstance(item, Undefined): + raise KeyError(key) + return item def __repr__(self): return '<%s %s of %r>' % ( -- 2.26.2