diff options
Diffstat (limited to 'Lib/xml/dom/minidom.py')
-rw-r--r-- | Lib/xml/dom/minidom.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py index 7e2f88e..275e20c 100644 --- a/Lib/xml/dom/minidom.py +++ b/Lib/xml/dom/minidom.py @@ -62,10 +62,7 @@ class Node(xml.dom.Node): return writer.stream.getvalue() def hasChildNodes(self): - if self.childNodes: - return True - else: - return False + return bool(self.childNodes) def _get_childNodes(self): return self.childNodes @@ -723,12 +720,16 @@ class Element(Node): Node.unlink(self) def getAttribute(self, attname): + if self._attrs is None: + return "" try: return self._attrs[attname].value except KeyError: return "" def getAttributeNS(self, namespaceURI, localName): + if self._attrsNS is None: + return "" try: return self._attrsNS[(namespaceURI, localName)].value except KeyError: @@ -926,6 +927,7 @@ class Childless: """Mixin that makes childless-ness easy to implement and avoids the complexity of the Node methods that deal with children. """ + __slots__ = () attributes = None childNodes = EmptyNodeList() @@ -1063,6 +1065,8 @@ defproperty(CharacterData, "length", doc="Length of the string data.") class Text(CharacterData): + __slots__ = () + nodeType = Node.TEXT_NODE nodeName = "#text" attributes = None @@ -1184,6 +1188,8 @@ class Comment(CharacterData): class CDATASection(Text): + __slots__ = () + nodeType = Node.CDATA_SECTION_NODE nodeName = "#cdata-section" @@ -1262,8 +1268,7 @@ defproperty(ReadOnlySequentialNamedNodeMap, "length", class Identified: """Mix-in class that supports the publicId and systemId attributes.""" - # XXX this does not work, this is an old-style class - # __slots__ = 'publicId', 'systemId' + __slots__ = 'publicId', 'systemId' def _identified_mixin_init(self, publicId, systemId): self.publicId = publicId |