Opened 15 years ago

Closed 15 years ago

Last modified 13 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: dev
Severity: Keywords:
Cc: petrilli@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 by James Snow, 15 years ago

Component: UncategorizedDatabase layer (models, ORM)

comment:2 by Chris Petrilli, 15 years ago

Cc: petrilli@… added

comment:3 by Russell Keith-Magee, 15 years ago

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 by Russell Keith-Magee, 15 years ago

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 by Russell Keith-Magee, 15 years ago

(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 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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