mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Fix various spots where int/long and str/unicode unification
lead to type checks like isinstance(foo, (str, str)) or isinstance(foo, (int, int)).
This commit is contained in:
parent
5d7a7001d9
commit
aa97f04964
14 changed files with 46 additions and 51 deletions
|
@ -741,32 +741,32 @@ class Decimal(object):
|
|||
return 1
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) == 0
|
||||
|
||||
def __ne__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) != 0
|
||||
|
||||
def __lt__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) < 0
|
||||
|
||||
def __le__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) <= 0
|
||||
|
||||
def __gt__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) > 0
|
||||
|
||||
def __ge__(self, other):
|
||||
if not isinstance(other, (Decimal, int, int)):
|
||||
if not isinstance(other, (Decimal, int)):
|
||||
return NotImplemented
|
||||
return self.__cmp__(other) >= 0
|
||||
|
||||
|
@ -2993,7 +2993,7 @@ def _convert_other(other):
|
|||
"""
|
||||
if isinstance(other, Decimal):
|
||||
return other
|
||||
if isinstance(other, (int, int)):
|
||||
if isinstance(other, int):
|
||||
return Decimal(other)
|
||||
return NotImplemented
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue