• Jeremy Hylton's avatar
    Ensure that new code produces pickles acceptable to old code. · c5f31d21
    Jeremy Hylton authored
    Add __getstate__() and __setstate__() methods.
    
    Thanks to Chris McDonough for helping me see the problem.
    
    There are extensive comments that discuss the backwards compatibility
    issues.  Basically, we must be careful that the pickles these methods
    operate on are just like the pickles generated by the old code, or
    developers couldn't switch back and forth between new and old code.
    That's a incompatibility we aren't willing to live with for now --
    perhaps not ever.
    
        # If the internal representation of PersistentMapping changes,
        # it causes compatibility problems for pickles generated by
        # different versions of the code.  Compatibility works in both
        # directions, because an application may want to share a database
        # between applications using different versions of the code.
    
        # Effectively, the original rep is part of the "API."  To provide
        # full compatibility, the getstate and setstate must read and
        # right objects using the old rep.
    
        # As a result, the PersistentMapping must save and restore the
        # actual internal dictionary using the name _container.
    c5f31d21
mapping.py 3.43 KB