zopefoundation/persistent — pull request #5 by jamadden (2014-02-18 19:41:40+00:00)
Title: Python __setstate__ fails if the instance dict contains exactly two values

If the python version of Persistent had `__setstate__` called with a dictionary containing exactly two items, it would fail at `idict.update(inst_dict)` with 'ValueError: sequence of pairs expected" due to incorrect tuple unpacking. I noticed this when trying to get `zope.container` to work with PyPy. `zope.container` has a persistent proxy class that contains exactly two variables, `__parent__` and `__name__` so its tests were failing::

File "zope.container/eggs/ZODB-4.0.0-py2.7.egg/ZODB/serialize.py", line 622, in getState
return unpickler.load()
File "pypy/lib_pypy/cPickle.py", line 170, in load
self.dispatch[key](self)
File "pypy/lib_pypy/cPickle.py", line 521, in load_build
setstate(state)
File "zope.container/eggs/persistent-4.0.6-py2.7.egg/persistent/persistence.py", line 300, in __setstate__
idict.update(inst_dict)
ValueError: sequence of pairs expected

This commit makes the python version do what the C version does and check for a tuple explicitly.