Opened 7 years ago

Closed 7 years ago

#29330 closed Bug (fixed)

Regression in master: cannot pickle queryset with expression

Reported by: Daniel Miller Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Removal of BaseExpression.__getstate__ in PR 9134 caused querysets with expressions derived from BaseExpression to no longer be pickle-able.

Error:

Traceback (most recent call last):
  File "/home/travis/build/millerdev/django-cte/tests/test_recursive.py", line 212, in test_pickle_recursive_cte_queryset
    pickled_qs = pickle.loads(pickle.dumps(regions))
AttributeError: Can't pickle local object 'BaseExpression.convert_value.<locals>.<lambda>'

Seen here: https://travis-ci.org/millerdev/django-cte/jobs/366128465

Steps to reproduce:

  • Clone django-cte
  • Make a virtualenv any way you prefer.
  • pip install git+https://github.com/django/django.git@master (or however you prefer to install django master).
  • pip install nose
  • nosetests tests.test_recursive:TestRecursiveCTE.test_pickle_recursive_cte_queryset
  • Observe pickle error.

Change History (3)

comment:1 by Daniel Miller, 7 years ago

Last edited 7 years ago by Daniel Miller (previous) (diff)

comment:2 by Tim Graham, 7 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 60156750:

Fixed #29330 -- Fixed crash when pickling BaseExpression.

Regression in cfff2af02be40106d4759cc6f8bfa476ce82421c.

Note: See TracTickets for help on using tickets.
Back to Top