From: Kirill S. <ki...@mn...> - 2010-03-01 17:40:57
|
Spot this by debugging Substitute transformation which does .deepcopy() to substitute definitions. This will be needed in the next patch, where I'll be teaching Inliner to propagate .line for `inline' elements. --- docutils/docutils/nodes.py | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docutils/docutils/nodes.py b/docutils/docutils/nodes.py index a68b545..804a98b 100644 --- a/docutils/docutils/nodes.py +++ b/docutils/docutils/nodes.py @@ -363,7 +363,11 @@ class Text(Node, reprunicode): # an infinite loop def copy(self): - return self.__class__(reprunicode(self), rawsource=self.rawsource) + obj = self.__class__(reprunicode(self), rawsource=self.rawsource) + obj.document = self.document + obj.source = self.source + obj.line = self.line + return obj def deepcopy(self): return self.copy() @@ -742,7 +746,11 @@ class Element(Node): for child in self.children]) def copy(self): - return self.__class__(**self.attributes) + obj = self.__class__(**self.attributes) + obj.document = self.document + obj.source = self.source + obj.line = self.line + return obj def deepcopy(self): copy = self.copy() @@ -1193,8 +1201,11 @@ class document(Root, Structural, Element): self.current_line = offset + 1 def copy(self): - return self.__class__(self.settings, self.reporter, + obj = self.__class__(self.settings, self.reporter, **self.attributes) + obj.source = self.source + obj.line = self.line + return obj def get_decoration(self): if not self.decoration: @@ -1472,8 +1483,12 @@ class pending(Special, Invisible, Element): for line in internals])) def copy(self): - return self.__class__(self.transform, self.details, self.rawsource, + obj = self.__class__(self.transform, self.details, self.rawsource, **self.attributes) + obj.document = self.document + obj.source = self.source + obj.line = self.line + return obj class raw(Special, Inline, PreBibliographic, FixedTextElement): -- 1.7.0.91.g9803 |