diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-10-29 12:04:00 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-10-29 12:04:00 (GMT) |
commit | 0c67312c5c0d5d44e065d2ecc5023d0e47f815ee (patch) | |
tree | d2c818a3a370db20f64487dcc93b2aae1154c0b2 /Lib/decimal.py | |
parent | 783b877555bbfa53663c4bf870e5fc3fa8259ea9 (diff) | |
download | cpython-0c67312c5c0d5d44e065d2ecc5023d0e47f815ee.zip cpython-0c67312c5c0d5d44e065d2ecc5023d0e47f815ee.tar.gz cpython-0c67312c5c0d5d44e065d2ecc5023d0e47f815ee.tar.bz2 |
Issue #7233: A number of two-argument Decimal methods were failing to
accept ints and longs for the second argument.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 7384d36..be1a827 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -2723,6 +2723,8 @@ class Decimal(object): value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2792,6 +2794,8 @@ class Decimal(object): Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3160,6 +3164,9 @@ class Decimal(object): """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3181,6 +3188,9 @@ class Decimal(object): """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3195,6 +3205,9 @@ class Decimal(object): """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3408,6 +3421,8 @@ class Decimal(object): if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3432,11 +3447,13 @@ class Decimal(object): return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3460,6 +3477,8 @@ class Decimal(object): if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans |