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

Deepcopy not working #73

guardeivid opened this issue Feb 27, 2019 · 2 comments

Deepcopy not working #73

guardeivid opened this issue Feb 27, 2019 · 2 comments


Copy link

Hi, I tried to use deepcopy and the following error occurs:

from copy import deepcopy
from mappyfile.ordereddict import DefaultOrderedDict

d = DefaultOrderedDict()
d['__type__'] = 'layer'

e = deepcopy(d)
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\Python36\lib\", line 91, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "<string>", line 18, in <module>
  File "C:\OSGeo4W\apps\Python36\lib\", line 161, in deepcopy
    y = copier(memo)
  File "C:\OSGeo4W\apps\Python36\lib\site-packages\mappyfile\", line 61, in __deepcopy__
  File "C:\OSGeo4W\apps\Python36\lib\", line 169, in deepcopy
    rv = reductor(4)
TypeError: can't pickle odict_items objects

This is happening in Python >= 3.5

Following the logic maybe it should be like this?


    def __deepcopy__(self, memo):
        return type(self)(self.default_factory, copy.deepcopy(iter(self.items())))
Copy link

@guardeivid - thanks for the report and suggested fix. Should be fixed with the commit - df590b5

I had to use list() rather than iter() or Python2 breaks. Unit test also added. This will be part of the next patch release.

Copy link


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

No branches or pull requests

2 participants