From: Armin Ronacher Date: Mon, 10 Sep 2007 14:03:32 +0000 (+0200) Subject: fixed error in error message (-.-) X-Git-Tag: 2.0rc1~272 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=005e17028187145444859b20897215100e6557d8;p=jinja2.git fixed error in error message (-.-) --HG-- branch : trunk --- diff --git a/jinja/parser.py b/jinja/parser.py index 28a037f..ff2684a 100644 --- a/jinja/parser.py +++ b/jinja/parser.py @@ -303,7 +303,8 @@ class Parser(object): # check if this block does not exist by now. if name in self.blocks: raise TemplateSyntaxError('block %r defined twice' % - name, lineno, self.filename) + name, token.lineno, + self.filename) self.blocks.add(name) if self.stream.current.type != 'block_end': diff --git a/jinja/utils.py b/jinja/utils.py index bdea9e6..9e8190c 100644 --- a/jinja/utils.py +++ b/jinja/utils.py @@ -215,17 +215,22 @@ def safe_range(start, stop=None, step=None): """ "Safe" form of range that does not generate too large lists. """ - # this also works with None since None is always smaller than - # any other value. - if start > MAX_RANGE: - start = MAX_RANGE - if stop > MAX_RANGE: - stop = MAX_RANGE if step is None: step = 1 if stop is None: - return range(0, start, step) - return range(start, stop, step) + r = xrange(0, start, step) + else: + r = xrange(start, stop, step) + if len(r) > MAX_RANGE: + def limit(): + i = 0 + for item in r: + i += 1 + yield item + if i >= MAX_RANGE: + break + return list(limit()) + return list(r) def generate_lorem_ipsum(n=5, html=True, min=20, max=100):