[issue4851] xml.dom.minidom.Element.cloneNode fails with AttributeError

Jean-Paul Calderone report at bugs.python.org
Mon Jan 5 23:00:10 CET 2009


New submission from Jean-Paul Calderone <exarkun at divmod.com>:

It seems impossible to clone an Element created without a document:

  >>> Element('foo').cloneNode(False)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.5/xml/dom/minidom.py", line 211, in cloneNode
      return _clone_node(self, deep, self.ownerDocument or self)
    File "/usr/lib/python2.5/xml/dom/minidom.py", line 1814, in _clone_node
      if node.ownerDocument.isSameNode(newOwnerDocument):
  AttributeError: 'NoneType' object has no attribute 'isSameNode'

The documentation claims that cloneNode was fixed for releases
"subsequent" to 2.0, but this doesn't appear to be true.

http://docs.python.org/library/xml.dom.minidom.html#xml.dom.minidom.Node.cloneNode

A similar issue occurs when attempting to import a node into a document
(something I tried as a work-around for this failure):

  >>> d.importNode(e, False)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.5/xml/dom/minidom.py", line 1737, in importNode
      return _clone_node(node, deep, self)
    File "/usr/lib/python2.5/xml/dom/minidom.py", line 1814, in _clone_node
      if node.ownerDocument.isSameNode(newOwnerDocument):
  AttributeError: 'NoneType' object has no attribute 'isSameNode'

----------
components: Library (Lib)
messages: 79203
nosy: exarkun
severity: normal
status: open
title: xml.dom.minidom.Element.cloneNode fails with AttributeError
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4851>
_______________________________________


More information about the Python-bugs-list mailing list