#5762: fix handling of empty namespace in minidom, which would result in AttributeError on toxml().
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 _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: