I've looked into a regression in 6029341 where the Node.__hash__ method was changed from using object.__hash__ to it's
own implementation using Node.iter_fields().
Since the fields contain lists, the resulting tuple is not hashable.
Test case:
class TestHashing:
def test_template_hash(self, env):
template = env.parse("hash test")
assert hash(template)
Output:
self = Template(body=[Output(nodes=[TemplateData(data='hash test')])])
def __hash__(self):
> return hash(tuple(self.iter_fields()))
E TypeError: unhashable type: 'list'
This behaviour breaks some third party packages such as django-compressor. See django-compressor/django-compressor#1060
Environment:
- Python version: 3.10
- Jinja version: 3.0.x
I've looked into a regression in 6029341 where the
Node.__hash__method was changed from usingobject.__hash__to it'sown implementation using
Node.iter_fields().Since the fields contain lists, the resulting tuple is not hashable.
Test case:
Output:
This behaviour breaks some third party packages such as
django-compressor. See django-compressor/django-compressor#1060Environment: