summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2014-04-30 17:15:38 (GMT)
committerStefan Krah <skrah@bytereef.org>2014-04-30 17:15:38 (GMT)
commitb151f8f60b3ea7199d4d98ec77f2e6fb03b8b7fb (patch)
tree7254b61d620d92178c03051cca8ad3cf715d55ad
parent5c2ac8c1c664d17924157ed769a7541c9228a1e3 (diff)
downloadcpython-b151f8f60b3ea7199d4d98ec77f2e6fb03b8b7fb.zip
cpython-b151f8f60b3ea7199d4d98ec77f2e6fb03b8b7fb.tar.gz
cpython-b151f8f60b3ea7199d4d98ec77f2e6fb03b8b7fb.tar.bz2
Issue #10650: Remove the non-standard 'watchexp' parameter from the
Decimal.quantize() method in the Python version. It had never been present in the C version.
-rw-r--r--Doc/library/decimal.rst12
-rw-r--r--Lib/decimal.py12
-rw-r--r--Lib/test/test_decimal.py12
-rw-r--r--Misc/NEWS4
4 files changed, 8 insertions, 32 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index aa526db..7052985 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -744,7 +744,7 @@ Decimal objects
* ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number).
* ``"sNaN"``, indicating that the operand is a signaling NaN.
- .. method:: quantize(exp, rounding=None, context=None, watchexp=True)
+ .. method:: quantize(exp, rounding=None, context=None)
Return a value equal to the first operand after rounding and having the
exponent of the second operand.
@@ -767,14 +767,8 @@ Decimal objects
``context`` argument; if neither argument is given the rounding mode of
the current thread's context is used.
- If *watchexp* is set (default), then an error is returned whenever the
- resulting exponent is greater than :attr:`Emax` or less than
- :attr:`Etiny`.
-
- .. deprecated:: 3.3
- *watchexp* is an implementation detail from the pure Python version
- and is not present in the C version. It will be removed in version
- 3.4, where it defaults to ``True``.
+ An error is returned whenever the resulting exponent is greater than
+ :attr:`Emax` or less than :attr:`Etiny`.
.. method:: radix()
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 5b98473..6d0b34c 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -2523,7 +2523,7 @@ class Decimal(object):
end -= 1
return _dec_from_triple(dup._sign, dup._int[:end], exp)
- def quantize(self, exp, rounding=None, context=None, watchexp=True):
+ def quantize(self, exp, rounding=None, context=None):
"""Quantize self so its exponent is the same as that of exp.
Similar to self._rescale(exp._exp) but with error checking.
@@ -2546,16 +2546,6 @@ class Decimal(object):
return context._raise_error(InvalidOperation,
'quantize with one INF')
- # if we're not watching exponents, do a simple rescale
- if not watchexp:
- ans = self._rescale(exp._exp, rounding)
- # raise Inexact and Rounded where appropriate
- if ans._exp > self._exp:
- context._raise_error(Rounded)
- if ans != self:
- context._raise_error(Inexact)
- return ans
-
# exp._exp should be between Etiny and Emax
if not (context.Etiny() <= exp._exp <= context.Emax):
return context._raise_error(InvalidOperation,
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 4b27907..339fe7c 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -4448,18 +4448,6 @@ class PyCoverage(Coverage):
class PyFunctionality(unittest.TestCase):
"""Extra functionality in decimal.py"""
- def test_py_quantize_watchexp(self):
- # watchexp functionality
- Decimal = P.Decimal
- localcontext = P.localcontext
-
- with localcontext() as c:
- c.prec = 1
- c.Emax = 1
- c.Emin = -1
- x = Decimal(99999).quantize(Decimal("1e3"), watchexp=False)
- self.assertEqual(x, Decimal('1.00E+5'))
-
def test_py_alternate_formatting(self):
# triples giving a format, a Decimal, and the expected result
Decimal = P.Decimal
diff --git a/Misc/NEWS b/Misc/NEWS
index 0e2447a..dc3a583 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,10 @@ Core and Builtins
Library
-------
+- Issue #10650: Remove the non-standard 'watchexp' parameter from the
+ Decimal.quantize() method in the Python version. It had never been
+ present in the C version.
+
- Issue #21321: itertools.islice() now releases the reference to the source
iterator when the slice is exhausted. Patch by Anton Afanasyev.