Issue #23326: Removed __ne__ implementations. Since fixing default __ne__

implementation in issue #21408 they are redundant.
This commit is contained in:
Serhiy Storchaka 2015-01-31 12:05:05 +02:00
parent 57f7db3122
commit 08448a1f4d
20 changed files with 3 additions and 104 deletions

View file

@ -923,15 +923,6 @@ def __eq__(self, other, context=None):
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:

View file

@ -1209,11 +1209,6 @@ def __eq__(self, other):
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__

View file

@ -178,10 +178,6 @@ def __eq__(self, other):
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)

View file

@ -987,7 +987,6 @@ def __repr__(self): return repr(self.data)
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 @@ def __eq__(self, string):
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

View file

@ -567,12 +567,6 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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

View file

@ -48,12 +48,6 @@ def __eq__(self, other):
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:

View file

@ -249,9 +249,6 @@ def __str__(self):
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.

View file

@ -262,9 +262,6 @@ def __eq__(self, other):
# 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.

View file

@ -223,8 +223,6 @@ def __le__(self, other):
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

View file

@ -2255,9 +2255,6 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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."""

View file

@ -41,7 +41,6 @@
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)

View file

@ -1305,8 +1305,6 @@ def __le__(self, other):
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):

View file

@ -69,9 +69,6 @@ def __repr__(self):
def __eq__(self, other):
return vars(self) == vars(other)
def __ne__(self, other):
return not (self == other)
class ArgumentParserError(Exception):

View file

@ -599,8 +599,6 @@ def _cmp__(self, other):
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):

View file

@ -2015,10 +2015,6 @@ def __eq__(self, other):
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='()')

View file

@ -185,11 +185,6 @@ def __eq__(self, other):
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.

View file

@ -545,9 +545,6 @@ def __le__(self, other):
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]

View file

@ -532,10 +532,6 @@ 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
# --------------------------------------------------------------------

View file

@ -340,10 +340,6 @@ def __eq__(self, other):
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 @@ def __eq__(self, other):
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)

View file

@ -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.