[Python-Dev] Change in unpickle order in 2.2?

M.-A. Lemburg mal@lemburg.com
Thu, 10 Jan 2002 20:02:02 +0100


Greg Ward wrote:
> 
> 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.

What's Grouch ?
 
> (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.)

Why don't you use a special reduce function which takes the
tp_name as index into the types module ? Storing strings should
avoid all complicated type object saving.
 
> 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?

You should probably first check wether the pickle string is
identical in 2.1 and 2.2 and then go on from there.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/