Issue 8257: Decimal constructor to accept float.
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 34463ae..80ef20d 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -648,8 +648,12 @@
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)