#32450: "TypeError: cannot pickle" when applying | operator to a Q object
-------------------------------------+-------------------------------------
     Reporter:  Daniel Izquierdo     |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Daniel Izquierdo:

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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2283c447891a92b73858f9af4af2bd4d%40djangoproject.com.

Reply via email to