Patch from Matt Keenan <matt.keenan@gmail.com> - 0005217: Number of text reports crashing during deepcopy() for Python <2.7

svn: r18156
This commit is contained in:
Brian Matherly 2011-09-12 02:40:13 +00:00
parent 3c283e1109
commit 269df644df

View File

@ -108,6 +108,21 @@ if not sys.version_info >= MIN_PYTHON_VERSION :
MIN_PYTHON_VERSION[2]))
sys.exit(1)
#-------------------------------------------------------------------------
#
# deepcopy workaround
#
#-------------------------------------------------------------------------
# In versions < 2.7 python does not properly copy methods when doing a
# deepcopy. This workaround makes the copy work properly. When Gramps no longer
# supports python 2.6, this workaround can be removed.
if sys.version_info < (2, 7) :
import copy
import types
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method
#-------------------------------------------------------------------------
#
# gramps libraries