cpython: fa0b1e50270f (original) (raw)
Mercurial > cpython
changeset 72571:fa0b1e50270f
merge #4147: minidom's toprettyxml no longer adds whitespace to text nodes. [#4147]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Sat, 01 Oct 2011 16:22:35 -0400 |
parents | 90a06fbb1f85(current diff)086ca132e161(diff) |
children | 9124a00df142 |
files | Lib/test/test_minidom.py Misc/ACKS Misc/NEWS |
diffstat | 4 files changed, 14 insertions(+), 2 deletions(-)[+] [-] Lib/test/test_minidom.py 7 Lib/xml/dom/minidom.py 6 Misc/ACKS 1 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -467,6 +467,13 @@ class MinidomTest(unittest.TestCase): dom.unlink() self.confirm(domstr == str.replace("\n", "\r\n"))
- def test_toPrettyXML_perserves_content_of_text_node(self):
str = '<A>B</A>'[](#l1.8)
dom = parseString(str)[](#l1.9)
dom2 = parseString(dom.toprettyxml())[](#l1.10)
self.assertEqual(dom.childNodes[0].childNodes[0].toxml(),[](#l1.11)
dom2.childNodes[0].childNodes[0].toxml())[](#l1.12)
+ def testProcessingInstruction(self): dom = parseString('') pi = dom.documentElement.firstChild
--- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -836,7 +836,9 @@ class Element(Node): _write_data(writer, attrs[a_name].value) writer.write(""") if self.childNodes:
writer.write(">%s"%(newl))[](#l2.7)
writer.write(">")[](#l2.8)
if self.childNodes[0].nodeType != Node.TEXT_NODE:[](#l2.9)
writer.write(newl)[](#l2.10) for node in self.childNodes:[](#l2.11) node.writexml(writer,indent+addindent,addindent,newl)[](#l2.12) writer.write("%s</%s>%s" % (indent,self.tagName,newl))[](#l2.13)
@@ -1061,7 +1063,7 @@ class Text(CharacterData): return newText def writexml(self, writer, indent="", addindent="", newl=""):
_write_data(writer, "%s%s%s"%(indent, self.data, newl))[](#l2.18)
_write_data(writer, self.data)[](#l2.19)
# DOM Level 3 (WD 9 April 2002)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -496,6 +496,7 @@ Lou Kates Hiroaki Kawai Sebastien Keim Ryan Kelly +Dan Kenigsberg Robert Kern Randall Kern Magnus Kessler
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -294,6 +294,8 @@ Core and Builtins Library ------- +- Issue #4147: minidom's toprettyxml no longer adds whitespace to text nodes. +