Kaydet (Commit) f207ffbd authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Sync-up with minor changes to the head.

üst b930fbd9
...@@ -515,7 +515,7 @@ class Decimal(object): ...@@ -515,7 +515,7 @@ class Decimal(object):
if isinstance(value, (list,tuple)): if isinstance(value, (list,tuple)):
if len(value) != 3: if len(value) != 3:
raise ValueError, 'Invalid arguments' raise ValueError, 'Invalid arguments'
if value[0] not in [0,1]: if value[0] not in (0,1):
raise ValueError, 'Invalid sign' raise ValueError, 'Invalid sign'
for digit in value[1]: for digit in value[1]:
if not isinstance(digit, (int,long)) or digit < 0: if not isinstance(digit, (int,long)) or digit < 0:
...@@ -760,18 +760,19 @@ class Decimal(object): ...@@ -760,18 +760,19 @@ class Decimal(object):
Captures all of the information in the underlying representation. Captures all of the information in the underlying representation.
""" """
if self._isnan(): if self._is_special:
minus = '-'*self._sign if self._isnan():
if self._int == (0,): minus = '-'*self._sign
info = '' if self._int == (0,):
else: info = ''
info = ''.join(map(str, self._int)) else:
if self._isnan() == 2: info = ''.join(map(str, self._int))
return minus + 'sNaN' + info if self._isnan() == 2:
return minus + 'NaN' + info return minus + 'sNaN' + info
if self._isinfinity(): return minus + 'NaN' + info
minus = '-'*self._sign if self._isinfinity():
return minus + 'Infinity' minus = '-'*self._sign
return minus + 'Infinity'
if context is None: if context is None:
context = getcontext() context = getcontext()
...@@ -1446,7 +1447,7 @@ class Decimal(object): ...@@ -1446,7 +1447,7 @@ class Decimal(object):
return float(str(self)) return float(str(self))
def __int__(self): def __int__(self):
"""Converts self to a int, truncating if necessary.""" """Converts self to an int, truncating if necessary."""
if self._is_special: if self._is_special:
if self._isnan(): if self._isnan():
context = getcontext() context = getcontext()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment