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

Skip to content

Commit 575712e

Browse files
committed
Tighten up the new NodeList implementation.
Clean up a little; do not create an alias that is only used once, or store attributes with constant values in an instance.
1 parent 88a5685 commit 575712e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/xml/dom/minidom.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,36 @@
3030
del types
3131

3232
import xml.dom
33-
_Node = xml.dom.Node
3433

3534

3635
if list is type([]):
3736
class NodeList(list):
37+
__dynamic__ = 0
38+
3839
def item(self, index):
3940
if 0 <= index < len(self):
4041
return self[index]
4142

42-
def __getattr__(self, name):
43-
if name == "length":
44-
return len(self)
45-
raise AttributeError, name
43+
length = property(lambda self: len(self),
44+
doc="The number of nodes in the NodeList.")
4645

4746
else:
4847
def NodeList():
4948
return []
5049

5150

52-
class Node(_Node):
51+
class Node(xml.dom.Node):
5352
allnodes = {}
5453
_debug = 0
5554
_makeParentNodes = 1
5655
debug = None
5756
childNodeTypes = ()
5857
namespaceURI = None # this is non-null only for elements and attributes
58+
parentNode = None
59+
ownerDocument = None
5960

6061
def __init__(self):
6162
self.childNodes = NodeList()
62-
self.parentNode = self.ownerDocument = None
6363
if Node._debug:
6464
index = repr(id(self)) + repr(self.__class__)
6565
Node.allnodes[index] = repr(self.__dict__)

0 commit comments

Comments
 (0)