diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_minidom.py | 7 | ||||
-rw-r--r-- | Lib/xml/dom/minidom.py | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index d9d3be4..97668d3 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -1489,6 +1489,13 @@ class MinidomTest(unittest.TestCase): doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml) + def testEmptyXMLNSValue(self): + doc = parseString("<element xmlns=''>\n" + "<foo/>\n</element>") + doc2 = parseString(doc.toxml()) + self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) + + def test_main(): run_unittest(MinidomTest) diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 1beae0c..81a1330 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -301,9 +301,10 @@ def _in_document(node): def _write_data(writer, data): "Writes datachars to writer." - data = data.replace("&", "&").replace("<", "<") - data = data.replace("\"", """).replace(">", ">") - writer.write(data) + if data: + data = data.replace("&", "&").replace("<", "<"). \ + replace("\"", """).replace(">", ">") + writer.write(data) def _get_elements_by_tagName_helper(parent, name, rc): for node in parent.childNodes: |