The VersionedUnpickler accepts an updater object:
|
def __init__(self, file, updater=None): |
|
Unpickler.__init__(self, file) |
|
self.updater = updater |
This was supposed to be its "interface":
|
class Updater: |
|
|
|
"""An abstract class to provide functionality common to the updaters.""" |
|
|
|
def get_latest(self, module, name): |
|
"""The refactorings dictionary contains mappings between old and new |
|
module names. Since we only bump the version number one increment |
|
there is only one possible answer. |
|
""" |
But from where it is used, there are more features expected of this interface, e.g. it is expected to have an attribute called setstates which is a dictionary:
|
fn = self.updater.setstates.get((module, name), False) |
The structure of this dictionary is not documented (and there seem to be no tests for it). It seems to be used for monkeypatching a class __setstate__ (a global state that does not belong to apptools!), but it may not be restored.
Monkeypatching here in the code path if VersionedUnpickler.updater is not None:
|
# hook up our __setstate__ which updates self.__dict__ |
|
setattr(klass, "__setstate__", __replacement_setstate__) |
To be restored if some other unpickler without an updater came across the same class:
|
# restore the original __setstate__ if necessary |
|
fn = getattr(klass, "__setstate_original__", False) |
|
if fn: |
|
setattr(klass, "__setstate__", fn) |
It is possible that no one uses an updater with the VersionedUnpickler so this monkeypatching is never exercised. I have not checked if there are other uses of an updater anywhere else. It could be a feature that can be removed.
The
VersionedUnpickleraccepts an updater object:apptools/apptools/persistence/versioned_unpickler.py
Lines 111 to 113 in 632a4bf
This was supposed to be its "interface":
apptools/apptools/persistence/updater.py
Lines 9 to 17 in 632a4bf
But from where it is used, there are more features expected of this interface, e.g. it is expected to have an attribute called
setstateswhich is a dictionary:apptools/apptools/persistence/versioned_unpickler.py
Line 157 in 632a4bf
The structure of this dictionary is not documented (and there seem to be no tests for it). It seems to be used for monkeypatching a class
__setstate__(a global state that does not belong to apptools!), but it may not be restored.Monkeypatching here in the code path if
VersionedUnpickler.updateris not None:apptools/apptools/persistence/versioned_unpickler.py
Lines 166 to 167 in 632a4bf
To be restored if some other unpickler without an updater came across the same class:
apptools/apptools/persistence/versioned_unpickler.py
Lines 145 to 148 in 632a4bf
It is possible that no one uses an updater with the
VersionedUnpicklerso this monkeypatching is never exercised. I have not checked if there are other uses of an updater anywhere else. It could be a feature that can be removed.