Skip to content

DefaultOrderedDict save it to a file with pickle #68

Closed
@guardeivid

Description

@guardeivid

Hi,
Excellent work.
I am trying to save the dictionary open with mappyfile in a file, using pickle, but I get the following error:

mapy = mappyfile.open(path)
pickle.dump(mapy, open('file', 'wb'))
_pickle.PicklingError: fifth element of the tuple returned by __reduce__ must be an iterator, not odict_items.

I understand that this is the function::

    def __reduce__(self):
        if self.default_factory is None:
            args = tuple()
        else:
            args = self.default_factory,
        return type(self), args, None, None, self.items()

Is it possible to return an iterator instead of self.items()?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions