[Python-checkins] cpython: Issue #10650: Remove the non-standard 'watchexp' parameter from the

stefan.krah python-checkins at python.org
Wed Apr 30 19:16:21 CEST 2014


http://hg.python.org/cpython/rev/c2f827af02a2
changeset:   90527:c2f827af02a2
user:        Stefan Krah <skrah at bytereef.org>
date:        Wed Apr 30 19:15:38 2014 +0200
summary:
  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.

files:
  Doc/library/decimal.rst  |  12 +++---------
  Lib/decimal.py           |  12 +-----------
  Lib/test/test_decimal.py |  12 ------------
  Misc/NEWS                |   4 ++++
  4 files changed, 8 insertions(+), 32 deletions(-)


diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -744,7 +744,7 @@
       * ``"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 @@
       ``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
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -2523,7 +2523,7 @@
             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 @@
                 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
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -4448,18 +4448,6 @@
 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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,10 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list