{{{
>>> from django.db.models import Q
>>> Q(x__in={}.keys())
<Q: (AND: ('x__in', dict_keys([])))>
>>> Q() | Q(x__in={}.keys())
Traceback (most recent call last):
...
TypeError: cannot pickle 'dict_keys' object
}}}
Even though this particular example could be solved by doing `Q() |
Q(x__in={})` it still feels like doing using `.keys()` should work.
I can work on a patch if there's agreement that this should not crash.
--
Ticket URL: <https://code.djangoproject.com/ticket/32450>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Using a reference to a non-pickleable type of object such as `dict_keys`
> in a `Q` object makes the `|` operator fail:
>
> {{{
> >>> from django.db.models import Q
> >>> Q(x__in={}.keys())
> <Q: (AND: ('x__in', dict_keys([])))>
> >>> Q() | Q(x__in={}.keys())
> Traceback (most recent call last):
> ...
> TypeError: cannot pickle 'dict_keys' object
> }}}
>
> Even though this particular example could be solved by doing `Q() |
> Q(x__in={})` it still feels like doing using `.keys()` should work.
>
> I can work on a patch if there's agreement that this should not crash.
New description:
Using a reference to a non-pickleable type of object such as `dict_keys`
in a `Q` object makes the `|` operator fail:
{{{
>>> from django.db.models import Q
>>> Q(x__in={}.keys())
<Q: (AND: ('x__in', dict_keys([])))>
>>> Q() | Q(x__in={}.keys())
Traceback (most recent call last):
...
TypeError: cannot pickle 'dict_keys' object
}}}
Even though this particular example could be solved by doing `Q() |
Q(x__in={})` it still feels like using `.keys()` should work.
I can work on a patch if there's agreement that this should not crash.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32450#comment:1>
* cc: Tom Forbes (added)
* stage: Unreviewed => Accepted
Comment:
Thanks for this report.
Regression in bb0b6e526340e638522e093765e534df4e4393d2.
--
Ticket URL: <https://code.djangoproject.com/ticket/32450#comment:2>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32450#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"466920f6d726eee90d5566e0a9948e92b33a122e" 466920f6]:
{{{
#!CommitTicketReference repository=""
revision="466920f6d726eee90d5566e0a9948e92b33a122e"
Fixed #32450 -- Fixed crash when ANDing/ORing an empty Q() with not
pickleable Q().
Regression in bb0b6e526340e638522e093765e534df4e4393d2.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32450#comment:4>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"0e2979e95d0f68f28c92c84c14655e7510d4e789" 0e2979e9]:
{{{
#!CommitTicketReference repository=""
revision="0e2979e95d0f68f28c92c84c14655e7510d4e789"
[3.2.x] Fixed #32450 -- Fixed crash when ANDing/ORing an empty Q() with
not pickleable Q().
Regression in bb0b6e526340e638522e093765e534df4e4393d2.
Backport of 466920f6d726eee90d5566e0a9948e92b33a122e from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32450#comment:5>