Opened 4 years ago
Last modified 4 years ago
#32450 closed Bug
"TypeError: cannot pickle" when applying | operator to a Q object — at Initial Version
Reported by: | Daniel Izquierdo | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | Tom Forbes | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.
Note:
See TracTickets
for help on using tickets.