[Python-bugs-list] [Bug #126866] (xml.dom.minidom.Document()).toxml() breakable
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 07 Jan 2001 20:05:28 -0800
Bug #126866, was updated on 2000-Dec-26 15:36
Here is a current snapshot of the bug.
Project: Python
Category: XML
Status: Closed
Resolution: Fixed
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, "&", "&")
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: 2001-Jan-07 20:05
By: fdrake
Comment:
Fixed in Lib/xml/dom/minidom.py revision 1.19.
If the parameter is not an 8-bit or Unicode string, TypeError is raised.
-------------------------------------------------------
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