Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: third_party/jinja2/nodes.py

Issue 23506004: Update Jinja2 (Python template library) to 2.7.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/jinja2/meta.py ('k') | third_party/jinja2/parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/jinja2/nodes.py
diff --git a/third_party/jinja2/nodes.py b/third_party/jinja2/nodes.py
index f9da1da5a295f364635ece012a746d3e3afc8814..c5697e6b5ec3737a0e43656c883340656c4544d3 100644
--- a/third_party/jinja2/nodes.py
+++ b/third_party/jinja2/nodes.py
@@ -13,13 +13,15 @@
:license: BSD, see LICENSE for more details.
"""
import operator
-from itertools import chain, izip
+
from collections import deque
-from jinja2.utils import Markup, MethodType, FunctionType
+from jinja2.utils import Markup
+from jinja2._compat import next, izip, with_metaclass, text_type, \
+ method_type, function_type
#: the types we support for context functions
-_context_function_types = (FunctionType, MethodType)
+_context_function_types = (function_type, method_type)
_binop_to_func = {
@@ -102,9 +104,9 @@ def get_eval_context(node, ctx):
return ctx
-class Node(object):
+class Node(with_metaclass(NodeType, object)):
"""Baseclass for all Jinja2 nodes. There are a number of nodes available
- of different types. There are three major types:
+ of different types. There are four major types:
- :class:`Stmt`: statements
- :class:`Expr`: expressions
@@ -118,7 +120,6 @@ class Node(object):
The `environment` attribute is set at the end of the parsing process for
all nodes automatically.
"""
- __metaclass__ = NodeType
fields = ()
attributes = ('lineno', 'environment')
abstract = True
@@ -142,7 +143,7 @@ class Node(object):
setattr(self, attr, attributes.pop(attr, None))
if attributes:
raise TypeError('unknown attribute %r' %
- iter(attributes).next())
+ next(iter(attributes)))
def iter_fields(self, exclude=None, only=None):
"""This method iterates over all fields that are defined and yields
@@ -231,6 +232,9 @@ class Node(object):
def __ne__(self, other):
return not self.__eq__(other)
+ # Restore Python 2 hashing behavior on Python 3
+ __hash__ = object.__hash__
+
def __repr__(self):
return '%s(%s)' % (
self.__class__.__name__,
@@ -440,7 +444,7 @@ class Const(Literal):
constant value in the generated code, otherwise it will raise
an `Impossible` exception.
"""
- from compiler import has_safe_repr
+ from .compiler import has_safe_repr
if not has_safe_repr(value):
raise Impossible()
return cls(value, lineno=lineno, environment=environment)
@@ -687,7 +691,7 @@ class Concat(Expr):
def as_const(self, eval_ctx=None):
eval_ctx = get_eval_context(self, eval_ctx)
- return ''.join(unicode(x.as_const(eval_ctx)) for x in self.nodes)
+ return ''.join(text_type(x.as_const(eval_ctx)) for x in self.nodes)
class Compare(Expr):
« no previous file with comments | « third_party/jinja2/meta.py ('k') | third_party/jinja2/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698