amt: ensure we initialize with Decimal type
This commit is contained in:
parent
e9a5bd4b65
commit
88eff0278d
1 changed files with 3 additions and 3 deletions
|
|
@ -134,19 +134,19 @@ class CoinAmt(Decimal, Hilite, InitErrors): # abstract class
|
|||
we must allow other to be int(0) to use the sum() builtin
|
||||
"""
|
||||
if type(other) in (type(self), Decimal) or (other == 0 and isinstance(other, int)):
|
||||
return type(self)(Decimal.__add__(self, other), from_decimal=True, decimals=decimals, **kwargs)
|
||||
return type(self)(Decimal(Decimal.__add__(self, other)), from_decimal=True, decimals=decimals, **kwargs)
|
||||
self.incorrect_type_error(other)
|
||||
|
||||
__radd__ = __add__
|
||||
|
||||
def __sub__(self, other, decimals=None, **kwargs):
|
||||
if type(other) in (type(self), Decimal):
|
||||
return type(self)(Decimal.__sub__(self, other), from_decimal=True, decimals=decimals, **kwargs)
|
||||
return type(self)(Decimal(Decimal.__sub__(self, other)), from_decimal=True, decimals=decimals, **kwargs)
|
||||
self.incorrect_type_error(other)
|
||||
|
||||
def __rsub__(self, other, decimals=None, **kwargs):
|
||||
if type(other) is type(self):
|
||||
return type(self)(Decimal.__rsub__(self, other), from_decimal=True, decimals=decimals, **kwargs)
|
||||
return type(self)(Decimal(Decimal.__rsub__(self, other)), from_decimal=True, decimals=decimals, **kwargs)
|
||||
self.incorrect_type_error(other)
|
||||
|
||||
def __mul__(self, other, decimals=None, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue