[Python-bugs-list] [Bug #126866] (xml.dom.minidom.Document()).toxml() breakable

noreply@sourceforge.net noreply@sourceforge.net
Sat, 30 Dec 2000 18:18:21 -0800


Bug #126866, was updated on 2000-Dec-26 15:36
Here is a current snapshot of the bug.

Project: Python
Category: XML
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: iainlamb
Assigned to : fdrake
Summary: (xml.dom.minidom.Document()).toxml() breakable

Details: Consider this code:

from xml.dom.minidom import Document
import sys
e = Exception()
try:
	raise e
except:
	type = sys.exc_info()[0]
	d = Document()
	node = d.createTextNode(type)
	d.appendChild(node)
	print d.toxml()

It's derived from a case where I inadvertently passed a non-string
object (I was trying to represent the exception type) into
createTextNode(). Run it and you'll get:

Traceback (most recent call last):
  File "<stdin>", line 11, in ?
  File "c:\python\lib\xml\dom\minidom.py", line 83, in toxml
    self.writexml(writer)
  File "c:\python\lib\xml\dom\minidom.py", line 461, in writexml
    node.writexml(writer)
  File "c:\python\lib\xml\dom\minidom.py", line 400, in writexml
    _write_data(writer, self.data)
  File "c:\python\lib\xml\dom\minidom.py", line 153, in _write_data
    data = string.replace(data, "&", "&amp;")
  File "c:\python\lib\string.py", line 363, in replace
    return s.replace(old, new, maxsplit)
AttributeError: replace

I suggest you convert the text node's contents to a string before
making the call to string.replace() in minidom.py

Thanks for a cool dom implementation!

- Iain Lamb


Follow-Ups:

Date: 2000-Dec-30 18:18
By: fdrake

Comment:
This will be fairly easy to fix; look for me to check it in early next week
(when I'm near a real workstation!).
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=126866&group_id=5470