]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Don't assign the range type each time. 214/head
authorCory Benfield <lukasaoz@gmail.com>
Sat, 18 May 2013 10:41:24 +0000 (11:41 +0100)
committerCory Benfield <lukasaoz@gmail.com>
Sat, 18 May 2013 10:41:24 +0000 (11:41 +0100)
jinja2/compiler.py

index 4ee39f89f793af71b78955fc2d3c297f74eae1cf..64a75cc300255b019b56e6cb7ad41b45daededca 100644 (file)
@@ -19,6 +19,12 @@ import six
 from six.moves import cStringIO as StringIO
 from six.moves import map, zip
 
+# TODO: Move this to the compat module.
+try:
+    range_type = xrange
+except NameError:
+    range_type = range
+
 
 operators = {
     'eq':       '==',
@@ -71,10 +77,6 @@ def has_safe_repr(value):
     """Does the node have a safe representation?"""
     if value is None or value is NotImplemented or value is Ellipsis:
         return True
-    try:
-        range_type = xrange
-    except NameError:
-        range_type = range
     if isinstance(value, (bool, int, float, complex, range_type, Markup) + six.string_types):
         return True
     if isinstance(value, (tuple, list, set, frozenset)):