diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-01-27 18:17:45 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-01-27 18:17:45 (GMT) |
commit | a56c467ac39ab1a6a2e9dc2fa41a9f573f989839 (patch) | |
tree | f65fc7d2a4359328f10c1dd9122a692e78e71e8a /Lib/xml | |
parent | 191e850053128f726d6562e1d8306dfe5e4aa8aa (diff) | |
download | cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.zip cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.gz cpython-a56c467ac39ab1a6a2e9dc2fa41a9f573f989839.tar.bz2 |
Issue #1717: Remove cmp. Stage 1: remove all uses of cmp and __cmp__ from
the standard library and tests.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/dom/minidom.py | 22 | ||||
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 26 |
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 |