diff options
author | Raymond Hettinger <python@rcn.com> | 2010-04-02 16:58:27 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-04-02 16:58:27 (GMT) |
commit | 967985989031ecfa1dab7dd4dc757d6d33c47157 (patch) | |
tree | 198889b00fedd199dc75467d32b92501e7c8b5af /Lib/decimal.py | |
parent | 63b4355c75d51ef3133464ae04adb94c5be9047a (diff) | |
download | cpython-967985989031ecfa1dab7dd4dc757d6d33c47157.zip cpython-967985989031ecfa1dab7dd4dc757d6d33c47157.tar.gz cpython-967985989031ecfa1dab7dd4dc757d6d33c47157.tar.bz2 |
Issue 8257: Decimal constructor to accept float argument.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 370eb82..ab38ed4 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -648,8 +648,12 @@ class Decimal(object): return self if isinstance(value, float): - raise TypeError("Cannot convert float in Decimal constructor. " - "Use from_float class method.") + value = Decimal.from_float(value) + self._exp = value._exp + self._sign = value._sign + self._int = value._int + self._is_special = value._is_special + return self raise TypeError("Cannot convert %r to Decimal" % value) |