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

bidict imcompatible with deepcopy and pickle #94

Closed
uduse opened this issue Sep 2, 2019 · 3 comments
Closed

bidict imcompatible with deepcopy and pickle #94

uduse opened this issue Sep 2, 2019 · 3 comments

Comments

@uduse
Copy link

uduse commented Sep 2, 2019

import copy
from bidict import bidict
d = bidict({0: 1, 2: 3})
d2 = copy.deepcopy(d)
x = d2.inv.inv

This raises:

~/Library/...
    169     def inv(self):
    170         """Alias for :attr:`inverse`."""
--> 171         return self.inverse
    172 
    173     def __getstate__(self):

~/Library/...
    159             return self._inv
    160         # Otherwise a weakref is stored in self._invweak. Try to get a strong ref from it.
--> 161         inv = self._invweak()
    162         if inv is not None:
    163             return inv

AttributeError: _invweak

In addition, this also raises the same error:

import pickle
from bidict import bidict
d = bidict({0: 1, 2: 3})
pickle.loads(pickle.dumps(d)).inv.inv
@uduse uduse changed the title bidict imcompatible with copy.deepcopy bidict imcompatible with deepcopy and pickle Sep 2, 2019
jab added a commit that referenced this issue Sep 2, 2019
@jab jab closed this as completed in 94d42de Sep 2, 2019
@jab
Copy link
Owner

jab commented Sep 2, 2019

Thank you for reporting @uduse. Just fixed. Would you like to test it on latest master before I publish a new release with the fix?

@uduse
Copy link
Author

uduse commented Sep 3, 2019

@jab works like a charm, thanks a lot for the quick fix!

@jab
Copy link
Owner

jab commented Sep 3, 2019

Thanks for confirming @uduse! The fix is now released in v0.18.1.

Hope you're finding bidict useful. If you'd like to share anything else about you and your use case, I'm always interested to better understand who is using bidict and how they're using it, how it could meet their needs better, and how they could more easily contribute if interested.

You can subscribe to new release notifications at https://libraries.io/pypi/bidict, and/or join the Gitter chat, where I announce new releases and solicit feedback on proposed changes. By default Gitter will email you about mentions you missed, but the chat room is very low activity, and it's easy to change your notification settings too.

Thanks again for reporting this issue, and look forward to crossing paths again.

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