New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultOrderedDict save it to a file with pickle #68

Closed
guardeivid opened this Issue Sep 28, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@guardeivid

guardeivid commented Sep 28, 2018

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!

geographika added a commit that referenced this issue Sep 29, 2018

@geographika

This comment has been minimized.

Owner

geographika commented Sep 29, 2018

@guardeivid - glad you like the library.
I added a pickle test but wasn't able to recreate the issue. Would you be able to provide a minimal Mapfile snippet that causes this?

@geographika

This comment has been minimized.

Owner

geographika commented Sep 29, 2018

Ok the pickle test works in Python2 and not Python3, I'll add a fix for this. Thanks for reporting.

@guardeivid

This comment has been minimized.

guardeivid commented Oct 1, 2018

Yes, the error was in Python3. Great now it works correctly,

Many Thanks!

@guardeivid guardeivid closed this Oct 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment