def _restore_reduce(self, obj):
        """
        Supports restoring with all elements of __reduce__ as per pep 307.
        Assumes that iterator items (the last two) are represented as lists
        as per pickler implementation.
        """
        reduce_val = obj[tags.REDUCE]
        f, args, state, listitems, dictitems = map(self._restore, reduce_val)

        if f == tags.NEWOBJ or f.__name__ == '__newobj__':
            # mandated special case
            cls = args[0]
            stage1 = cls.__new__(cls, *args[1:])
        else:
            stage1 = f(*args)

        if state:
            try:
                stage1.__setstate__(state)
            except AttributeError:
                # it's fine - we'll try the prescribed default methods
                try:
                    stage1.__dict__.update(state)
                except AttributeError:
                    # next prescribed default
                    for k, v in state.items():
                        setattr(stage1, k, v)

        if listitems:
            # should be lists if not None
            try:
                stage1.extend(listitems)
            except __HOLE__:
                for x in listitems:
                    stage1.append(x)

        if dictitems:
            for k, v in dictitems:
                stage1.__setitem__(k, v)

        self._mkref(stage1)
        return stage1
dataset/ETHPy150Open jsonpickle/jsonpickle/jsonpickle/unpickler.py/Unpickler._restore_reduce