Skip to content
Snippets Groups Projects
Commit 346fceeb authored by Matt Wala's avatar Matt Wala
Browse files

Apparently, __getstate__() results are coerced to bool in Python 2

and __setstate__() doesn't run if the state is False.

Ensure that we always return a non-false state (another version bump
here).
parent 33311179
No related branches found
No related tags found
1 merge request!89Lazily unpickling dictionary
Pipeline #
......@@ -396,12 +396,9 @@ class LazilyUnpicklingDictionary(collections.MutableMapping):
return iter(self._map)
def __getstate__(self):
return dict(
return {"_map": dict(
(key, _PickledObjectWrapper.from_object(val))
for key, val in six.iteritems(self._map))
def __setstate__(self, state):
self._map = state
for key, val in six.iteritems(self._map))}
# }}}
......
......@@ -32,4 +32,4 @@ except ImportError:
else:
_islpy_version = islpy.version.VERSION_TEXT
DATA_MODEL_VERSION = "v57-islpy%s" % _islpy_version
DATA_MODEL_VERSION = "v58-islpy%s" % _islpy_version
......@@ -97,7 +97,7 @@ class PicklableItem(object):
flags = {"unpickled": False}
def __getstate__(self):
return ()
return True
def __setstate__(self, state):
PicklableItem.flags["unpickled"] = True
......@@ -135,6 +135,14 @@ def test_LazilyUnpicklingDictionary():
# }}}
# {{{ test empty map
mapping = LazilyUnpicklingDictionary({})
mapping = loads(dumps(mapping))
assert len(mapping) == 0
# }}}
if __name__ == "__main__":
if len(sys.argv) > 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment