changeset: 90527:c2f827af02a2 user: Stefan Krah date: Wed Apr 30 19:15:38 2014 +0200 files: Doc/library/decimal.rst Lib/decimal.py Lib/test/test_decimal.py Misc/NEWS description: 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. diff -r 981242c8fc86 -r c2f827af02a2 Doc/library/decimal.rst --- a/Doc/library/decimal.rst Wed Apr 30 11:06:16 2014 -0400 +++ b/Doc/library/decimal.rst Wed Apr 30 19:15:38 2014 +0200 @@ -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 -r 981242c8fc86 -r c2f827af02a2 Lib/decimal.py --- a/Lib/decimal.py Wed Apr 30 11:06:16 2014 -0400 +++ b/Lib/decimal.py Wed Apr 30 19:15:38 2014 +0200 @@ -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 -r 981242c8fc86 -r c2f827af02a2 Lib/test/test_decimal.py --- a/Lib/test/test_decimal.py Wed Apr 30 11:06:16 2014 -0400 +++ b/Lib/test/test_decimal.py Wed Apr 30 19:15:38 2014 +0200 @@ -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 -r 981242c8fc86 -r c2f827af02a2 Misc/NEWS --- a/Misc/NEWS Wed Apr 30 11:06:16 2014 -0400 +++ b/Misc/NEWS Wed Apr 30 19:15:38 2014 +0200 @@ -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.