Skip to content
Myr

Merge pull request #1522 from klette/fix-node-hash

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use `object.__hash__` for `Node.__hash__`

authored by David Lord · committed by GitHub · parents c0130ea, 9b96b48 · Browse files · 3 files+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−2 removed

  • tests:+3 added−0 removed
  • other:+3 added−2 removed

3 files+6 added−2 removed

modified:src/jinja2/nodes.py+1 added-2 removed
239 unmodified lines
240 return NotImplemented241242 return tuple(self.iter_fields()) == tuple(other.iter_fields())243244 def __hash__(self) -> int:245 return hash(tuple(self.iter_fields()))244 __hash__ = object.__hash__245246 def __repr__(self) -> str:247 args_str = ", ".join(f"{a}={getattr(self, a, None)!r}" for a in self.fields)248 return f"{type(self).__name__}({args_str})"
956 unmodified lines
added:tests/test_nodes.py+3 added
1def test_template_hash(env):2 template = env.parse("hash test")3 hash(template)
modified:CHANGES.rst+2 added
9 unmodified lines
10- Fix how the native environment treats leading and trailing spaces11 when parsing values on Python 3.10. :pr:`1537`12- Improve async performance by avoiding checks for common types.13 :issue:`1514`14- Revert change to ``hash(Node)`` behavior. Nodes are hashed by id15 again :issue:`1521`161718Version 3.0.219-------------
894 unmodified lines