From 9b36dfc04b7ac2414d5be8c55edb4194d78f4b88 Mon Sep 17 00:00:00 2001 From: milde Date: Wed, 21 Aug 2013 22:01:21 +0000 Subject: [PATCH] Apply patch by Jakub Wilk to fix bug [ 100 ]. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7717 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/HISTORY.txt | 3 +++ docutils/docutils/writers/odf_odt/__init__.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 653c319ac..c1b3ec8aa 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -16,6 +16,9 @@ Changes Since 0.11 ================== +* docutils/writers/odf_odt/__init__.py + + - Apply patch by Jakub Wilk to fix bug [ 100 ]. Release 0.11 (2013-07-22) ========================= diff --git a/docutils/docutils/writers/odf_odt/__init__.py b/docutils/docutils/writers/odf_odt/__init__.py index f02500513..2a2222683 100644 --- a/docutils/docutils/writers/odf_odt/__init__.py +++ b/docutils/docutils/writers/odf_odt/__init__.py @@ -88,16 +88,20 @@ except ImportError: # that support for the ability to get the parent of an element. # if WhichElementTree == 'elementtree': - class _ElementInterfaceWrapper(etree._ElementInterface): + import weakref + _parents = weakref.WeakKeyDictionary() + if isinstance(etree.Element, type): + _ElementInterface = etree.Element + else: + _ElementInterface = etree._ElementInterface + class _ElementInterfaceWrapper(_ElementInterface): def __init__(self, tag, attrib=None): - etree._ElementInterface.__init__(self, tag, attrib) - if attrib is None: - attrib = {} - self.parent = None + _ElementInterface.__init__(self, tag, attrib) + _parents[self] = None def setparent(self, parent): - self.parent = parent + _parents[self] = parent def getparent(self): - return self.parent + return _parents[self] # -- 2.11.4.GIT