Skip to content

Commit

Permalink
Merge pull request #1522 from klette/fix-node-hash
Browse files Browse the repository at this point in the history
Use `object.__hash__` for `Node.__hash__`
  • Loading branch information
davidism committed Nov 9, 2021
2 parents c0130ea + 9b96b48 commit 6aa096a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -11,6 +11,8 @@ Unreleased
when parsing values on Python 3.10. :pr:`1537`
- Improve async performance by avoiding checks for common types.
:issue:`1514`
- Revert change to ``hash(Node)`` behavior. Nodes are hashed by id
again :issue:`1521`


Version 3.0.2
Expand Down
3 changes: 1 addition & 2 deletions src/jinja2/nodes.py
Expand Up @@ -241,8 +241,7 @@ def __eq__(self, other: t.Any) -> bool:

return tuple(self.iter_fields()) == tuple(other.iter_fields())

def __hash__(self) -> int:
return hash(tuple(self.iter_fields()))
__hash__ = object.__hash__

def __repr__(self) -> str:
args_str = ", ".join(f"{a}={getattr(self, a, None)!r}" for a in self.fields)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_nodes.py
@@ -0,0 +1,3 @@
def test_template_hash(env):
template = env.parse("hash test")
hash(template)

0 comments on commit 6aa096a

Please sign in to comment.