diff options
| author | Mark Dickinson <dickinsm@gmail.com> | 2008-05-04 02:05:06 (GMT) | 
|---|---|---|
| committer | Mark Dickinson <dickinsm@gmail.com> | 2008-05-04 02:05:06 (GMT) | 
| commit | 8aca9d032e7813da9a23fd0771c008aff5a5e62f (patch) | |
| tree | 465d380f89fb740868bb82dc562ddbaae7dc28de /Lib/decimal.py | |
| parent | 979395b7a8be422dfc9a081f1cd77260c6ea9aef (diff) | |
| download | cpython-8aca9d032e7813da9a23fd0771c008aff5a5e62f.zip cpython-8aca9d032e7813da9a23fd0771c008aff5a5e62f.tar.gz cpython-8aca9d032e7813da9a23fd0771c008aff5a5e62f.tar.bz2  | |
Some very minor changes to decimal.py in Python 2.6, aimed
at reducing the size of the diff between the 2.x decimal.py
and 3.x decimal.py and thereby making future merges easier:
- replace one instnace of an old-style raise statement
- define __div__ in terms of __truediv__ instead of the
  other way around
- make wording match on an exception message
Diffstat (limited to 'Lib/decimal.py')
| -rw-r--r-- | Lib/decimal.py | 18 | 
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 13e2239..6a70ed0 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -1206,7 +1206,7 @@ class Decimal(object):          return ans      __rmul__ = __mul__ -    def __div__(self, other, context=None): +    def __truediv__(self, other, context=None):          """Return self / other."""          other = _convert_other(other)          if other is NotImplemented: @@ -1265,8 +1265,6 @@ class Decimal(object):          ans = _dec_from_triple(sign, str(coeff), exp)          return ans._fix(context) -    __truediv__ = __div__ -      def _divide(self, other, context):          """Return (self // other, self % other), to context.prec precision. @@ -1300,13 +1298,15 @@ class Decimal(object):                                     'quotient too large in //, % or divmod')          return ans, ans -    def __rdiv__(self, other, context=None): -        """Swaps self/other and returns __div__.""" +    def __rtruediv__(self, other, context=None): +        """Swaps self/other and returns __truediv__."""          other = _convert_other(other)          if other is NotImplemented:              return other -        return other.__div__(self, context=context) -    __rtruediv__ = __rdiv__ +        return other.__truediv__(self, context=context) + +    __div__ = __truediv__ +    __rdiv__ = __rtruediv__      def __divmod__(self, other, context=None):          """ @@ -1506,7 +1506,7 @@ class Decimal(object):                  context = getcontext()                  return context._raise_error(InvalidContext)              elif self._isinfinity(): -                raise OverflowError("Cannot convert infinity to long") +                raise OverflowError("Cannot convert infinity to int")          s = (-1)**self._sign          if self._exp >= 0:              return s*int(self._int)*10**self._exp @@ -3677,7 +3677,7 @@ class Context(object):          # Errors should only be risked on copies of the context          # self._ignored_flags = [] -        raise error, explanation +        raise error(explanation)      def _ignore_all_flags(self):          """Ignore all flags, if they are raised"""  | 
