summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/dom/minidom.py22
-rw-r--r--Lib/xml/etree/ElementTree.py26
2 files changed, 43 insertions, 5 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 3025ed7..489ae52 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -520,11 +520,29 @@ class NamedNodeMap(object):
__len__ = _get_length
- def __cmp__(self, other):
+ def _cmp(self, other):
if self._attrs is getattr(other, "_attrs", None):
return 0
else:
- return cmp(id(self), id(other))
+ return (id(self) > id(other)) - (id(self) < id(other))
+
+ def __eq__(self, other):
+ return self._cmp(other) == 0
+
+ def __ge__(self, other):
+ return self._cmp(other) >= 0
+
+ def __gt__(self, other):
+ return self._cmp(other) > 0
+
+ def __le__(self, other):
+ return self._cmp(other) <= 0
+
+ def __lt__(self, other):
+ return self._cmp(other) < 0
+
+ def __ne__(self, other):
+ return self._cmp(other) != 0
def __getitem__(self, attname_or_tuple):
if isinstance(attname_or_tuple, tuple):
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 782af81..cfac4f7 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -498,10 +498,30 @@ class QName:
return self.text
def __hash__(self):
return hash(self.text)
- def __cmp__(self, other):
+ def __le__(self, other):
if isinstance(other, QName):
- return cmp(self.text, other.text)
- return cmp(self.text, other)
+ return self.text <= other.text
+ return self.text <= other
+ def __lt__(self, other):
+ if isinstance(other, QName):
+ return self.text < other.text
+ return self.text < other
+ def __ge__(self, other):
+ if isinstance(other, QName):
+ return self.text >= other.text
+ return self.text >= other
+ def __gt__(self, other):
+ if isinstance(other, QName):
+ return self.text > other.text
+ return self.text > other
+ def __eq__(self, other):
+ if isinstance(other, QName):
+ return self.text == other.text
+ return self.text == other
+ def __ne__(self, other):
+ if isinstance(other, QName):
+ return self.text != other.text
+ return self.text != other
##
# ElementTree wrapper class. This class represents an entire element