Code

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#12538 closed (fixed)

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

Reported by: snow0x2d0 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.

Attachments (0)

Change History (6)

comment:1 Changed 5 years ago by snow0x2d0

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by petrilli

  • Cc petrilli@… added

comment:3 Changed 4 years ago by russellm

  • Component changed from Database layer (models, ORM) to Documentation
  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:5 Changed 4 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.