Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use object.__hash__ for Node.__hash__ #1522

Merged
merged 1 commit into from Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)