From a3152745414dacd9c2b8bafcfdffb670ebe6c5ff Mon Sep 17 00:00:00 2001 From: Benjamin Wiegand Date: Mon, 28 Apr 2008 18:07:52 +0200 Subject: [PATCH] fixed some NameErrors --HG-- branch : trunk --- jinja2/exceptions.py | 6 ++++++ jinja2/ext.py | 2 +- jinja2/filters.py | 1 + jinja2/nodes.py | 3 ++- jinja2/parser.py | 2 +- jinja2/utils.py | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/jinja2/exceptions.py b/jinja2/exceptions.py index 0bbe33e..b0853c4 100644 --- a/jinja2/exceptions.py +++ b/jinja2/exceptions.py @@ -45,3 +45,9 @@ class TemplateAssertionError(TemplateSyntaxError): class TemplateRuntimeError(TemplateError): """A runtime error.""" + + +class FilterArgumentError(Exception): + """This error is raised if a filter was called with inappropriate + arguments + """ diff --git a/jinja2/ext.py b/jinja2/ext.py index 5ae317d..1158505 100644 --- a/jinja2/ext.py +++ b/jinja2/ext.py @@ -15,7 +15,7 @@ from jinja2 import nodes from jinja2.environment import get_spontaneous_environment from jinja2.runtime import Undefined, concat from jinja2.parser import statement_end_tokens -from jinja2.exceptions import TemplateAssertionError +from jinja2.exceptions import TemplateAssertionError, TemplateSyntaxError from jinja2.utils import import_string, Markup diff --git a/jinja2/filters.py b/jinja2/filters.py index 4c9766c..0b55760 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -19,6 +19,7 @@ from urllib import urlencode, quote from itertools import imap, groupby from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode from jinja2.runtime import Undefined +from jinja2.exceptions import FilterArgumentError _striptags_re = re.compile(r'(|<[^>]*>)') diff --git a/jinja2/nodes.py b/jinja2/nodes.py index f87bbb8..c1231ea 100644 --- a/jinja2/nodes.py +++ b/jinja2/nodes.py @@ -504,7 +504,8 @@ class Subscript(Expr): if self.ctx != 'load': raise Impossible() try: - return environmen.subscribe(self.node.as_const(), self.arg.as_const()) + return self.environment.subscribe(self.node.as_const(), + self.arg.as_const()) except: raise Impossible() diff --git a/jinja2/parser.py b/jinja2/parser.py index 8bc1307..f225ab3 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -535,7 +535,7 @@ class Parser(object): if len(args) == 1: arg = args[0] else: - arg = nodes.Tuple(args, lineno, self.filename) + arg = nodes.Tuple(args, self.lineno, self.filename) else: raise TemplateSyntaxError('expected subscript expression', self.lineno, self.filename) diff --git a/jinja2/utils.py b/jinja2/utils.py index 639cda6..0704bb4 100644 --- a/jinja2/utils.py +++ b/jinja2/utils.py @@ -412,7 +412,7 @@ try: from functools import partial except ImportError: class partial(object): - def __init__(self, _func, *args, **kwargs): + def __init__(self, func, *args, **kwargs): self._func = func self._args = args self._kwargs = kwargs -- 2.26.2