diff --git a/src/gramps.py b/src/gramps.py index 9289ba23b..0621454c9 100644 --- a/src/gramps.py +++ b/src/gramps.py @@ -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