Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb67ea1

Browse files
committed
Initialize Attr.value with empty string in createAttribute*, as per DOM
spec. Closes bug #412036. Also reindent toprettyxml.
1 parent 68ad64a commit cb67ea1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/xml/dom/minidom.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ def toxml(self):
8787
return writer.getvalue()
8888

8989
def toprettyxml(self, indent="\t", newl="\n"):
90-
# indent = the indentation string to prepend, per level
91-
# newl = the newline string to append
92-
writer = _get_StringIO()
93-
self.writexml(writer, "", indent, newl)
94-
return writer.getvalue()
90+
# indent = the indentation string to prepend, per level
91+
# newl = the newline string to append
92+
writer = _get_StringIO()
93+
self.writexml(writer, "", indent, newl)
94+
return writer.getvalue()
9595

9696
def hasChildNodes(self):
9797
if self.childNodes:
@@ -794,6 +794,7 @@ def createProcessingInstruction(self, target, data):
794794
def createAttribute(self, qName):
795795
a = Attr(qName)
796796
a.ownerDocument = self
797+
a.value = ""
797798
return a
798799

799800
def createElementNS(self, namespaceURI, qualifiedName):
@@ -806,6 +807,7 @@ def createAttributeNS(self, namespaceURI, qualifiedName):
806807
prefix, localName = _nssplit(qualifiedName)
807808
a = Attr(qualifiedName, namespaceURI, localName, prefix)
808809
a.ownerDocument = self
810+
a.value = ""
809811
return a
810812

811813
def getElementsByTagNameNS(self, namespaceURI, localName):

0 commit comments

Comments
 (0)