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

Incompatible with Jinja2 v3 #1060

Closed
magicl opened this issue May 28, 2021 · 4 comments · Fixed by #1087
Closed

Incompatible with Jinja2 v3 #1060

magicl opened this issue May 28, 2021 · 4 comments · Fixed by #1087
Milestone

Comments

@magicl
Copy link

magicl commented May 28, 2021

File "django-compressor/compressor/management/commands/compress.py", line 207, in compress template_nodes = compressor_nodes.setdefault(template, OrderedDict()) File "jinja2/nodes.py", line 245, in __hash__ return hash(tuple(self.iter_fields())) TypeError: unhashable type: 'list'

Also tried the latest version on develop (as of today).

@diox diox added this to the 3.0 milestone May 28, 2021
@jonaseriksson84
Copy link

Also running into this problem.

@carltongibson
Copy link
Contributor

This is a change in behaviour between Jinja2 v2 and Jinja2 v3.

@AlekseiKhatkevich
Copy link

Same issue

klette added a commit to klette/jinja that referenced this issue Oct 27, 2021
This fixes a regression in commit 6029341 that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: django-compressor/django-compressor#1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
klette added a commit to klette/jinja that referenced this issue Oct 27, 2021
This fixes a regression in commit 6029341 that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: django-compressor/django-compressor#1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
davidism pushed a commit to klette/jinja that referenced this issue Nov 9, 2021
This fixes a regression in commit 6029341 that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: django-compressor/django-compressor#1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
davidism pushed a commit to klette/jinja that referenced this issue Nov 9, 2021
This fixes a regression in commit 6029341 that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: django-compressor/django-compressor#1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
@carltongibson
Copy link
Contributor

The change here was reverted in Jinga v3.0.3 See pallets/jinja#1522.

Anyone want to confirm?

carltongibson added a commit to carltongibson/django-compressor that referenced this issue Dec 7, 2021
Shows compatibility with Jinja v3.
Closes django-compressor#1060.
carltongibson added a commit that referenced this issue Dec 7, 2021
Shows compatibility with Jinja v3.
Closes #1060.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants