]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Initialize Attr.value with empty string in createAttribute*, as per DOM
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 31 Mar 2001 16:30:40 +0000 (16:30 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 31 Mar 2001 16:30:40 +0000 (16:30 +0000)
spec. Closes bug #412036.
Also reindent toprettyxml.

Lib/xml/dom/minidom.py

index 72ec5e05f7cef7df77798d866d2f9aedee8067b8..81315e729d8d3a5911d24473caf1c5495d18ac93 100644 (file)
@@ -87,11 +87,11 @@ class Node(_Node):
         return writer.getvalue()
 
     def toprettyxml(self, indent="\t", newl="\n"):
-      # indent = the indentation string to prepend, per level
-      # newl = the newline string to append
-      writer = _get_StringIO()
-      self.writexml(writer, "", indent, newl)
-      return writer.getvalue()
+        # indent = the indentation string to prepend, per level
+        # newl = the newline string to append
+        writer = _get_StringIO()
+        self.writexml(writer, "", indent, newl)
+        return writer.getvalue()
 
     def hasChildNodes(self):
         if self.childNodes:
@@ -794,6 +794,7 @@ class Document(Node):
     def createAttribute(self, qName):
         a = Attr(qName)
         a.ownerDocument = self
+        a.value = ""
         return a
 
     def createElementNS(self, namespaceURI, qualifiedName):
@@ -806,6 +807,7 @@ class Document(Node):
         prefix, localName = _nssplit(qualifiedName)
         a = Attr(qualifiedName, namespaceURI, localName, prefix)
         a.ownerDocument = self
+        a.value = ""
         return a
 
     def getElementsByTagNameNS(self, namespaceURI, localName):