Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index eda09e4..7b85806 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -281,9 +281,10 @@
Construct a new :class:`Decimal` object based from *value*.
- *value* can be an integer, string, tuple, or another :class:`Decimal` object. If
- no *value* is given, returns ``Decimal("0")``. If *value* is a string, it
- should conform to the decimal numeric string syntax::
+ *value* can be an integer, string, tuple, or another :class:`Decimal`
+ object. If no *value* is given, returns ``Decimal("0")``. If *value* is a
+ string, it should conform to the decimal numeric string syntax after leading
+ and trailing whitespace characters are removed::
sign ::= '+' | '-'
digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
@@ -313,6 +314,10 @@
Once constructed, :class:`Decimal` objects are immutable.
+ .. versionchanged:: 2.6
+ leading and trailing whitespace characters are permitted when
+ creating a Decimal instance from a string.
+
Decimal floating point objects share many properties with the other built-in
numeric types such as :class:`float` and :class:`int`. All of the usual math
operations and special methods apply. Likewise, decimal objects can be copied,
@@ -973,6 +978,9 @@
>>> Decimal("3.4445") + Decimal(0) + Decimal("1.0023")
Decimal("4.44")
+ This method implements the to-number operation of the IBM
+ specification. If the argument is a string, no leading or trailing
+ whitespace is permitted.
.. method:: Context.Etiny()