]> granicus.if.org Git - python/commitdiff
Issue #23326: Removed __ne__ implementations. Since fixing default __ne__
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 31 Jan 2015 10:05:05 +0000 (12:05 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 31 Jan 2015 10:05:05 +0000 (12:05 +0200)
implementation in issue #21408 they are redundant.

20 files changed:
Lib/_pydecimal.py
Lib/argparse.py
Lib/asyncio/events.py
Lib/collections/__init__.py
Lib/datetime.py
Lib/distutils/version.py
Lib/email/charset.py
Lib/email/header.py
Lib/functools.py
Lib/inspect.py
Lib/sched.py
Lib/test/datetimetester.py
Lib/test/test_argparse.py
Lib/test/test_long.py
Lib/unittest/mock.py
Lib/uuid.py
Lib/xml/dom/minidom.py
Lib/xml/etree/ElementTree.py
Lib/xmlrpc/client.py
Misc/NEWS

index 659e370ca6a6b536db832c11e51fbe375405c1a9..ca6c4bd98d416d7d1c3ab168928e9317cc0dc9e0 100644 (file)
@@ -923,15 +923,6 @@ class Decimal(object):
             return False
         return self._cmp(other) == 0
 
-    def __ne__(self, other, context=None):
-        self, other = _convert_for_comparison(self, other, equality_op=True)
-        if other is NotImplemented:
-            return other
-        if self._check_nans(other, context):
-            return True
-        return self._cmp(other) != 0
-
-
     def __lt__(self, other, context=None):
         self, other = _convert_for_comparison(self, other)
         if other is NotImplemented:
index be276bb62ff41457f745280910c3341d5089dcfb..ba9e3df3806179880a3526fbcdf193dac1b9e7fe 100644 (file)
@@ -1209,11 +1209,6 @@ class Namespace(_AttributeHolder):
             return NotImplemented
         return vars(self) == vars(other)
 
-    def __ne__(self, other):
-        if not isinstance(other, Namespace):
-            return NotImplemented
-        return not (self == other)
-
     def __contains__(self, key):
         return key in self.__dict__
 
index 8a7bb814a31939daa8931861d0e71f1af819ce03..01320cdf62bf2e2af1ec098fb57cead77318097b 100644 (file)
@@ -178,10 +178,6 @@ class TimerHandle(Handle):
                     self._cancelled == other._cancelled)
         return NotImplemented
 
-    def __ne__(self, other):
-        equal = self.__eq__(other)
-        return NotImplemented if equal is NotImplemented else not equal
-
     def cancel(self):
         if not self._cancelled:
             self._loop._timer_handle_cancelled(self)
index 7925af6050a1a1fdef0f3d23579366079fb260d4..ce67f0b31250a4fe7a9171c4dd3840148985bbde 100644 (file)
@@ -987,7 +987,6 @@ class UserList(MutableSequence):
     def __lt__(self, other): return self.data <  self.__cast(other)
     def __le__(self, other): return self.data <= self.__cast(other)
     def __eq__(self, other): return self.data == self.__cast(other)
-    def __ne__(self, other): return self.data != self.__cast(other)
     def __gt__(self, other): return self.data >  self.__cast(other)
     def __ge__(self, other): return self.data >= self.__cast(other)
     def __cast(self, other):
@@ -1064,10 +1063,6 @@ class UserString(Sequence):
         if isinstance(string, UserString):
             return self.data == string.data
         return self.data == string
-    def __ne__(self, string):
-        if isinstance(string, UserString):
-            return self.data != string.data
-        return self.data != string
     def __lt__(self, string):
         if isinstance(string, UserString):
             return self.data < string.data
index 86c80c3101c1804237f0efb4c51778879d6c2d25..4afe9a53814db202bc6ba3cd3d417b24ead8734f 100644 (file)
@@ -567,12 +567,6 @@ class timedelta:
         else:
             return False
 
-    def __ne__(self, other):
-        if isinstance(other, timedelta):
-            return self._cmp(other) != 0
-        else:
-            return True
-
     def __le__(self, other):
         if isinstance(other, timedelta):
             return self._cmp(other) <= 0
@@ -804,11 +798,6 @@ class date:
             return self._cmp(other) == 0
         return NotImplemented
 
-    def __ne__(self, other):
-        if isinstance(other, date):
-            return self._cmp(other) != 0
-        return NotImplemented
-
     def __le__(self, other):
         if isinstance(other, date):
             return self._cmp(other) <= 0
@@ -1079,12 +1068,6 @@ class time:
         else:
             return False
 
-    def __ne__(self, other):
-        if isinstance(other, time):
-            return self._cmp(other, allow_mixed=True) != 0
-        else:
-            return True
-
     def __le__(self, other):
         if isinstance(other, time):
             return self._cmp(other) <= 0
@@ -1651,14 +1634,6 @@ class datetime(date):
         else:
             return False
 
-    def __ne__(self, other):
-        if isinstance(other, datetime):
-            return self._cmp(other, allow_mixed=True) != 0
-        elif not isinstance(other, date):
-            return NotImplemented
-        else:
-            return True
-
     def __le__(self, other):
         if isinstance(other, datetime):
             return self._cmp(other) <= 0
index ebcab84e4e23fd525f5017dc4969082fdf404fbc..af14cc1348144745673ccd57a168d728b17b7e28 100644 (file)
@@ -48,12 +48,6 @@ class Version:
             return c
         return c == 0
 
-    def __ne__(self, other):
-        c = self._cmp(other)
-        if c is NotImplemented:
-            return c
-        return c != 0
-
     def __lt__(self, other):
         c = self._cmp(other)
         if c is NotImplemented:
index e999472355eec1b2730fa9a05b21b80b4668a72d..ee564040c68f8b3572757693bc3d5dc375fe80ce 100644 (file)
@@ -249,9 +249,6 @@ class Charset:
     def __eq__(self, other):
         return str(self) == str(other).lower()
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
     def get_body_encoding(self):
         """Return the content-transfer-encoding used for body encoding.
 
index 9c89589e6ebf9cd034a00af2ec38888de26a4fa3..6820ea16baf3d1379e651c5d3b5391fd4e368d8d 100644 (file)
@@ -262,9 +262,6 @@ class Header:
         # args and do another comparison.
         return other == str(self)
 
-    def __ne__(self, other):
-        return not self == other
-
     def append(self, s, charset=None, errors='strict'):
         """Append a string to the MIME header.
 
index fa5bfdef091a6b9991d28f4cd086162ebde22b0c..20a26f9a2c7583b3b1d5b420e0b65dcd5ee8f33d 100644 (file)
@@ -223,8 +223,6 @@ def cmp_to_key(mycmp):
             return mycmp(self.obj, other.obj) <= 0
         def __ge__(self, other):
             return mycmp(self.obj, other.obj) >= 0
-        def __ne__(self, other):
-            return mycmp(self.obj, other.obj) != 0
         __hash__ = None
     return K
 
index b789d66b5b782cea76cbca305c9eee48474dec67..98d665dd45f7fe76dd3ae6d840b503a3e2674f77 100644 (file)
@@ -2255,9 +2255,6 @@ class Parameter:
                 self._default == other._default and
                 self._annotation == other._annotation)
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
 
 class BoundArguments:
     """Result of `Signature.bind` call.  Holds the mapping of arguments
@@ -2342,9 +2339,6 @@ class BoundArguments:
                 self.signature == other.signature and
                 self.arguments == other.arguments)
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
 
 class Signature:
     """A Signature object represents the overall signature of a function.
@@ -2559,9 +2553,6 @@ class Signature:
         return (isinstance(other, Signature) and
                 self._hash_basis() == other._hash_basis())
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
     def _bind(self, args, kwargs, *, partial=False):
         """Private method. Don't use directly."""
 
index 409d126ef5e82272ec7ee3236755f81810b9a781..b47648d973a954129174c15110f020d2474f44ac 100644 (file)
@@ -41,7 +41,6 @@ __all__ = ["scheduler"]
 
 class Event(namedtuple('Event', 'time, priority, action, argument, kwargs')):
     def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
-    def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
     def __lt__(s, o): return (s.time, s.priority) <  (o.time, o.priority)
     def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority)
     def __gt__(s, o): return (s.time, s.priority) >  (o.time, o.priority)
index 564ff5224397d4b8073075b0fcb868638ff0c7cf..7935cf23204d09fa0976464e52a4ba95c4445cba 100644 (file)
@@ -1305,8 +1305,6 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
                 return isinstance(other, LargerThanAnything)
             def __eq__(self, other):
                 return isinstance(other, LargerThanAnything)
-            def __ne__(self, other):
-                return not isinstance(other, LargerThanAnything)
             def __gt__(self, other):
                 return not isinstance(other, LargerThanAnything)
             def __ge__(self, other):
index d7e6cda60a5fe50a0a3dc0f7a8da1b72c7e038c3..a0b91628aca0586a873ee48faf039a5dc2c04438 100644 (file)
@@ -69,9 +69,6 @@ class NS(object):
     def __eq__(self, other):
         return vars(self) == vars(other)
 
-    def __ne__(self, other):
-        return not (self == other)
-
 
 class ArgumentParserError(Exception):
 
index 5f14795649a1e72c3eca4cc0c16b213425f8d272..57847d88f74802177645a6546c339bb269975152 100644 (file)
@@ -599,8 +599,6 @@ class LongTest(unittest.TestCase):
                 return (x > y) - (x < y)
             def __eq__(self, other):
                 return self._cmp__(other) == 0
-            def __ne__(self, other):
-                return self._cmp__(other) != 0
             def __ge__(self, other):
                 return self._cmp__(other) >= 0
             def __gt__(self, other):
index 9d9b3e21ccac2165eab58b8dc1f9b651e5bbac0c..3b7c157c7d475e819e4eb883864f842503f6e5a4 100644 (file)
@@ -2015,10 +2015,6 @@ class _Call(tuple):
         return (other_args, other_kwargs) == (self_args, self_kwargs)
 
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-
     def __call__(self, *args, **kwargs):
         if self.name is None:
             return _Call(('', args, kwargs), name='()')
index 7b0b413966c0afed021dda8b67275ffad9479063..e627573969cb929a7429c7f72927f784907e16dc 100644 (file)
@@ -185,11 +185,6 @@ class UUID(object):
             return self.int == other.int
         return NotImplemented
 
-    def __ne__(self, other):
-        if isinstance(other, UUID):
-            return self.int != other.int
-        return NotImplemented
-
     # Q. What's the value of being able to sort UUIDs?
     # A. Use them as keys in a B-Tree or similar mapping.
 
index c76b14d6a4c2eb4abddcd873eefbc5178b33cbd8..a5d813f932ace36e2dbf8afcd780ca48551a3b81 100644 (file)
@@ -545,9 +545,6 @@ class NamedNodeMap(object):
     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):
             return self._attrsNS[attname_or_tuple]
index ca6c7d6f7188fec3709c0958d4072b33fa389dfc..4c109a2f612ff03354f359be463addd5fea83b38 100644 (file)
@@ -532,10 +532,6 @@ class QName:
         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
 
 # --------------------------------------------------------------------
 
index 9435015144937826eb83269e88623583fc4fd68e..047929a8611d4440d7102630a60433a2e02dbc02 100644 (file)
@@ -340,10 +340,6 @@ class DateTime:
         s, o = self.make_comparable(other)
         return s == o
 
-    def __ne__(self, other):
-        s, o = self.make_comparable(other)
-        return s != o
-
     def timetuple(self):
         return time.strptime(self.value, "%Y%m%dT%H:%M:%S")
 
@@ -407,11 +403,6 @@ class Binary:
             other = other.data
         return self.data == other
 
-    def __ne__(self, other):
-        if isinstance(other, Binary):
-            other = other.data
-        return self.data != other
-
     def decode(self, data):
         self.data = base64.decodebytes(data)
 
index 01af9d6f6f0de9ac81d0a1810aa8d220cd957de8..1588a2228e86d71a713f1e99a302daf0794e80a2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -226,6 +226,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #23326: Removed __ne__ implementations.  Since fixing default __ne__
+  implementation in issue #21408 they are redundant.
+
 - Issue #14099: Restored support of writing ZIP files to tellable but
   non-seekable streams.