summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-10-15 17:58:45 (GMT)
committerGeorg Brandl <georg@python.org>2010-10-15 17:58:45 (GMT)
commitb9cd72a9f776bc2b517e22af444dc14268f50b41 (patch)
tree7792769589a501efcdedce5cd4356c5bcffa06aa /Lib/xml/dom
parentd4460aaacdae40505a4645a73c021bfc810c9cb3 (diff)
downloadcpython-b9cd72a9f776bc2b517e22af444dc14268f50b41.zip
cpython-b9cd72a9f776bc2b517e22af444dc14268f50b41.tar.gz
cpython-b9cd72a9f776bc2b517e22af444dc14268f50b41.tar.bz2
#5762: fix handling of empty namespace in minidom, which would result in AttributeError on toxml().
Diffstat (limited to 'Lib/xml/dom')
-rw-r--r--Lib/xml/dom/minidom.py7
1 files changed, 4 insertions, 3 deletions
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("&", "&amp;").replace("<", "&lt;")
- data = data.replace("\"", "&quot;").replace(">", "&gt;")
- writer.write(data)
+ if data:
+ data = data.replace("&", "&amp;").replace("<", "&lt;"). \
+ replace("\"", "&quot;").replace(">", "&gt;")
+ writer.write(data)
def _get_elements_by_tagName_helper(parent, name, rc):
for node in parent.childNodes: