[Python-Dev] Change in unpickle order in 2.2?
Guido van Rossum
guido@python.org
Fri, 11 Jan 2002 00:08:43 -0500
> I have an application (Grouch) that has to do a lot of trickery at
> pickle-time and unpickle-time, and as a result it happens to be
> sensitive to the order of unpickling.
>
> (The reason for the pickle-time intervention is that Grouch stores type
> objects in its data structure, and you can't pickle type objects. So it
> hangs on to a representive value of the type for pickling -- eg. for the
> "integer" type, it keeps both IntType and 0 in memory, but only pickles
> 0, and uses type(0) to get IntType back at unpickle time.)
>
> The reason that Grouch is sensitive to the order of unpickling is
> because its data structure is a gnarly, incestuous knot of mutually
> interdependent classes, and I stopped tinkering with the pickle code as
> soon as I got something that worked with Python 2.0 and 2.1. Now it
> fails under 2.2. Under 2.1, it appears that certain more-deeply nested
> objects were unpickled first; under 2.2, that is no longer the case, and
> that screws up Grouch's test suite.
>
> Anyone got a vague, hand-waving explanation for my vague, hand-waving
> complaint? Or should I try to come up with a test case?
Yes please, and post it to SourceForge. There aren't that many
changes in the source of pickle.py since release 2.1. (Or are you
using cPickle? If so, please say so. The two aren't 100%
equivalent.)
I see changes related to unicode, and type objects are pickled
differently in 2.2. There's also a change that refuses to pickle an
"global" (a reference by module and object name, used for classes,
types and functions) when the name that the object claims to have
doesn't refer to the same object. There's a new test on
__safe_for_unpickling__.
Hm, I think you must be using cPickle, I don't know enough about it to
help.
--Guido van Rossum (home page: http://www.python.org/~guido/)