[Django] #29838: Hashing list in Q objects when using __in lookup

6 views
Skip to first unread message

Django

unread,
Oct 10, 2018, 5:19:40 PM10/10/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
--------------------------------------+-----------------------------------
Reporter: aspalding | Owner: aspalding
Type: Bug | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Keywords: hash, tuple, list
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+-----------------------------------
This bug was previously reported here - #29643.

However I am still getting this error upon rendering QuerySets that use
the Q object and include the `__in` filter in the most recent release of
django, 2.1.2.

Here is my reproduction of the bug on master:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
>>> q = Q(a__in=[1, 2])
>>> q.__hash__()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/aspalding/Documents/django/django/utils/tree.py", line 89,
in __hash__
for child in self.children
TypeError: unhashable type: 'list'
}}}
}}}

Therefor the minimal reproduction for `NodeTest` would look like:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
hash(Node([('a', [1, 2])]))
}}}
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29838>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 10, 2018, 5:41:53 PM10/10/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+--------------------------------------

Reporter: aspalding | Owner: aspalding
Type: Bug | Status: assigned
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: hash, tuple, list | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by aspalding):

[https://github.com/django/django/pull/10502 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:1>

Django

unread,
Oct 11, 2018, 11:25:22 AM10/11/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+------------------------------------
Reporter: Andrew | Owner: Andrew
Type: Bug | Status: assigned
Component: Utilities | Version: 2.0
Severity: Release blocker | Resolution:
Keywords: hash, tuple, list | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* version: master => 2.0
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

It qualifies for a backport to stable/2.1.x since it's a regression in
508b5debfb16843a8443ebac82c1fb91f15da687.

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:2>

Django

unread,
Oct 17, 2018, 11:55:09 AM10/17/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+------------------------------------
Reporter: Andrew | Owner: Andrew
Type: Bug | Status: assigned

Component: Utilities | Version: 2.0
Severity: Release blocker | Resolution:
Keywords: hash, tuple, list | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"217f82d7139fd32f07adbfa92c5fb383d0ade577" 217f82d7]:
{{{
#!CommitTicketReference repository=""
revision="217f82d7139fd32f07adbfa92c5fb383d0ade577"
Refs #29838 -- Fixed make_hashable() for values that have lists or dicts
nested in tuples.

And for non-hashable values that are iterable, e.g. sets.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:3>

Django

unread,
Oct 17, 2018, 11:55:10 AM10/17/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+------------------------------------
Reporter: Andrew | Owner: Andrew
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Release blocker | Resolution: fixed
Keywords: hash, tuple, list | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"dc5e75d419893bde33b7e439b59bdf271fc1a3f2" dc5e75d4]:
{{{
#!CommitTicketReference repository=""
revision="dc5e75d419893bde33b7e439b59bdf271fc1a3f2"
Fixed #29838 -- Fixed crash when combining Q objects with __in lookups and
lists.

Regression in fc6528b25ab1834be1a478b405bf8f7ec5cf860c.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:4>

Django

unread,
Oct 17, 2018, 11:55:42 AM10/17/18
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+------------------------------------
Reporter: Andrew | Owner: Andrew
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Release blocker | Resolution: fixed
Keywords: hash, tuple, list | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"0df7ea1b87d9543995156d5c5c77886fc1a5a615" 0df7ea1]:
{{{
#!CommitTicketReference repository=""
revision="0df7ea1b87d9543995156d5c5c77886fc1a5a615"
[2.1.x] Fixed #29838 -- Fixed crash when combining Q objects with __in
lookups and lists.

Regression in fc6528b25ab1834be1a478b405bf8f7ec5cf860c.

Backport of 834c4ec8e4cfc43acf0525e0a4d8c914534f6afd,
217f82d7139fd32f07adbfa92c5fb383d0ade577, and
dc5e75d419893bde33b7e439b59bdf271fc1a3f2 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:5>

Django

unread,
Oct 5, 2020, 3:14:14 PM10/5/20
to django-...@googlegroups.com
#29838: Hashing list in Q objects when using __in lookup
-----------------------------------+------------------------------------
Reporter: Andrew | Owner: Andrew
Type: Bug | Status: closed
Component: Utilities | Version: 2.0
Severity: Release blocker | Resolution: fixed
Keywords: hash, tuple, list | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"4c675523bd3e45906bf6736444c65b066e25208c" 4c67552]:
{{{
#!CommitTicketReference repository=""
revision="4c675523bd3e45906bf6736444c65b066e25208c"
Refs #29838, Refs #28507 -- Made make_hashable() ignore key order.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29838#comment:6>

Reply all
Reply to author
Forward
0 new messages