Issue #2482: Make sure that the coefficient of a Decimal

instance is always stored as a str instance, even
when that Decimal has been created from a unicode string.
This commit is contained in:
Mark Dickinson 2008-03-25 18:47:59 +00:00
parent cdde579fb9
commit 8e85ffa4b2
3 changed files with 23 additions and 3 deletions

View file

@ -557,17 +557,17 @@ class Decimal(object):
fracpart = m.group('frac')
exp = int(m.group('exp') or '0')
if fracpart is not None:
self._int = (intpart+fracpart).lstrip('0') or '0'
self._int = str((intpart+fracpart).lstrip('0') or '0')
self._exp = exp - len(fracpart)
else:
self._int = intpart.lstrip('0') or '0'
self._int = str(intpart.lstrip('0') or '0')
self._exp = exp
self._is_special = False
else:
diag = m.group('diag')
if diag is not None:
# NaN
self._int = diag.lstrip('0')
self._int = str(diag.lstrip('0'))
if m.group('signal'):
self._exp = 'N'
else: