"plugins/amoeba/vscode:/vscode.git/clone" did not exist on "10b51d251a193936ce11893d5fd014dde3d1965d"
Unverified Commit 9c866ca1 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1948 from Lnaden/bond_py27_pickle

Fix Bond pickling in Python 2.7
parents 07c1b86c f8624c4e
...@@ -465,6 +465,14 @@ class Bond(namedtuple('Bond', ['atom1', 'atom2'])): ...@@ -465,6 +465,14 @@ class Bond(namedtuple('Bond', ['atom1', 'atom2'])):
"Support for pickle protocol 2: http://docs.python.org/2/library/pickle.html#pickling-and-unpickling-normal-class-instances" "Support for pickle protocol 2: http://docs.python.org/2/library/pickle.html#pickling-and-unpickling-normal-class-instances"
return self[0], self[1], self.type, self.order return self[0], self[1], self.type, self.order
def __getstate__(self):
"""
Additional support for pickle since parent class implements its own __getstate__
so pickle does not store or restore the type and order, python 2 problem only
https://www.python.org/dev/peps/pep-0307/#case-3-pickling-new-style-class-instances-using-protocol-2
"""
return self.__dict__
def __deepcopy__(self, memo): def __deepcopy__(self, memo):
return Bond(self[0], self[1], self.type, self.order) return Bond(self[0], self[1], self.type, self.order)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment