Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12538 closed (fixed)

Removal (rename) of BaseQuery in SVN version causes ImportError for previously pickled Querysets

Reported by: James Snow Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: petrilli@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The issue seems to be that pickling a Queryset's query attribute per the documentation pickles a BaseQuery object. With Query taking the place of BaseQuery in the current svn version an attempt to unpickle a pickled BaseQuery object results in an import error. I don't have a particularly deep understanding of how cPickle and pickle work but my guess is that pickle attempts to instantiate a new object based on the pickled object's __module__ and __class__ values. If there isn't a simple fix for this it seems the documentation should at least be ammended to warn of the issue.

Change History (6)

comment:1 Changed 7 years ago by James Snow

Component: UncategorizedDatabase layer (models, ORM)

comment:2 Changed 7 years ago by Chris Petrilli

Cc: petrilli@… added

comment:3 Changed 7 years ago by Russell Keith-Magee

Component: Database layer (models, ORM)Documentation
milestone: 1.2
Triage Stage: UnreviewedAccepted

There's almost no way that we could protect against this sort of problem. Any change to the internals of a class like Query - which *will* happen between Django versions - will inevitably lead to unpickling problems, as the old class won't be compatible with the new class. Even if we hadn't renamed BaseQuery->Query, this would have still been a problem due to the massive internal refactoring of the Query class itself.

A documentation note to the effect of "pickles won't survive a version update" on the queryset pickling docs is about the best we can do here.

comment:4 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [12560]) Fixed #12538 -- Added a note that pickles aren't stable during version updates. Thanks to snow0x2d0 for the suggestion.

comment:5 Changed 7 years ago by Russell Keith-Magee

(In [12565]) [1.1.X] Fixed #12538 -- Added a note that pickles aren't stable during version updates. Thanks to snow0x2d0 for the suggestion.

Backport of r12560 from trunk.

comment:6 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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