mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
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:
parent
cdde579fb9
commit
8e85ffa4b2
3 changed files with 23 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue