From b07514e0d1d402e7568440cbac1dd8d344ebeed9 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 13 Oct 2011 10:32:27 +0000 Subject: [PATCH] Copy deepcopy fix to src/web (thanks P. Franklin); removed workaround svn: r18314 --- src/plugins/textreport/AncestorReport.py | 7 +------ src/plugins/textreport/DetAncestralReport.py | 7 +------ src/web/settings.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/textreport/AncestorReport.py b/src/plugins/textreport/AncestorReport.py index 0b9151268..15d961d02 100644 --- a/src/plugins/textreport/AncestorReport.py +++ b/src/plugins/textreport/AncestorReport.py @@ -31,7 +31,6 @@ #------------------------------------------------------------------------ import math import copy -import sys from gen.ggettext import gettext as _ #------------------------------------------------------------------------ @@ -109,11 +108,7 @@ class AncestorReport(Report): # Copy the global NameDisplay so that we don't change application # defaults. - try: - self._name_display = copy.deepcopy(global_name_display) - except: - print >> sys.stderr, "WARNING: unable to deepcopy name_display; continuing..." - self._name_display = global_name_display + self._name_display = copy.deepcopy(global_name_display) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) diff --git a/src/plugins/textreport/DetAncestralReport.py b/src/plugins/textreport/DetAncestralReport.py index 28832a312..84e3dc7ff 100644 --- a/src/plugins/textreport/DetAncestralReport.py +++ b/src/plugins/textreport/DetAncestralReport.py @@ -34,7 +34,6 @@ # #------------------------------------------------------------------------ import copy -import sys from gen.ggettext import gettext as _ #------------------------------------------------------------------------ @@ -141,11 +140,7 @@ class DetAncestorReport(Report): # Copy the global NameDisplay so that we don't change application # defaults. - try: - self._name_display = copy.deepcopy(global_name_display) - except: - print >> sys.stderr, "WARNING: unable to deepcopy name_display; continuing..." - self._name_display = global_name_display + self._name_display = copy.deepcopy(global_name_display) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: diff --git a/src/web/settings.py b/src/web/settings.py index 8dfaef29d..3fa576d3f 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -130,3 +130,13 @@ CACHE_BACKEND = 'locmem://' TRANSACTIONS_MANAGED = False LOCALE_PATHS = tuple() +# 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. +import sys +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