[albatross-users] pickle problem

Andrew McNamara andrewm at object-craft.com.au
Mon May 2 15:25:08 EST 2005


>> If you're playing tricks with the class definition at run-time, this will
>> also confound the pickler, I think (eg, metaclasses), or maybe changing the
>> instance's class at run-time.
>
>Another way to make it happen bit me a long time ago.
>
>If you reload a module then try to pickle an object created by the old 
>module before it was reloaded, then the pickle will fail.

Yes, this is one facet of what I had in mind when I said "changing the
instance's class at run-time". Sorry for not expressing it more clearly.

>I reported this as a Python bug, but Guido said that he does not 
>consider it to be a bug.
>
>http://sourceforge.net/tracker/index.php?func=detail&aid=451547&group_id=5470&atid=105470

The reload() documentation says:

    If a module instantiates instances of a class, reloading the module
    that defines the class does not affect the method definitions of the
    instances -- they continue to use the old class definition. The same
    is true for derived classes.

Unfortunately, you only look at this after wasting a day finding your
pickle bug! I'm sure if someone submitted a patch to the pickle doco...

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



More information about the Albatross-users mailing list