'Load object state from data returned by a get_state call.'

def set_state(self, state):

    state = state.copy()
    for (attr, cls) in self._stateobject_attributes.items():
        val = state.pop(attr)
        if (val is None):
            setattr(self, attr, val)
        else:
            curr = getattr(self, attr)
            if hasattr(curr, 'set_state'):
                curr.set_state(val)
            elif hasattr(cls, 'from_state'):
                obj = cls.from_state(val)
                setattr(self, attr, obj)
            elif _is_list(cls):
                cls = (cls.__parameters__[0] if cls.__parameters__ else cls.__args__[0])
                setattr(self, attr, [cls.from_state(x) for x in val])
            else:
                setattr(self, attr, cls(val))
    if state:
        raise RuntimeWarning('Unexpected    State    in    __setstate__:    {}'.format(state))
