Skip to content
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
Closed

DefaultOrderedDict save it to a file with pickle #68

guardeivid opened this issue Sep 28, 2018 · 3 comments

Comments

@guardeivid
Copy link

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
Copy link
Owner

@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
Copy link
Owner

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

@guardeivid
Copy link
Author

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

Many Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants