Commit 0c346d82 authored by Mark Dickinson's avatar Mark Dickinson

Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than...

Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than TypeError.  Patch by Josh Rosenberg.
parent 138185fa
...@@ -1085,7 +1085,7 @@ class BuiltinTest(unittest.TestCase): ...@@ -1085,7 +1085,7 @@ class BuiltinTest(unittest.TestCase):
if isinstance(x, float) or \ if isinstance(x, float) or \
isinstance(y, float) or \ isinstance(y, float) or \
isinstance(z, float): isinstance(z, float):
self.assertRaises(TypeError, pow, x, y, z) self.assertRaises(ValueError, pow, x, y, z)
else: else:
self.assertAlmostEqual(pow(x, y, z), 24.0) self.assertAlmostEqual(pow(x, y, z), 24.0)
......
...@@ -1111,6 +1111,7 @@ Armin Ronacher ...@@ -1111,6 +1111,7 @@ Armin Ronacher
Case Roole Case Roole
Timothy Roscoe Timothy Roscoe
Erik Rose Erik Rose
Josh Rosenberg
Jim Roskind Jim Roskind
Brian Rosner Brian Rosner
Guido van Rossum Guido van Rossum
......
...@@ -10,6 +10,9 @@ Release date: TBA ...@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #21193: pow(a, b, c) now raises ValueError rather than TypeError when b
is negative. Patch by Josh Rosenberg.
- PEP 465 and Issue #21176: Add the '@' operator for matrix multiplication. - PEP 465 and Issue #21176: Add the '@' operator for matrix multiplication.
- Issue #21134: Fix segfault when str is called on an uninitialized - Issue #21134: Fix segfault when str is called on an uninitialized
......
...@@ -3841,7 +3841,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x) ...@@ -3841,7 +3841,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
if (Py_SIZE(b) < 0) { /* if exponent is negative */ if (Py_SIZE(b) < 0) { /* if exponent is negative */
if (c) { if (c) {
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " PyErr_SetString(PyExc_ValueError, "pow() 2nd argument "
"cannot be negative when 3rd argument specified"); "cannot be negative when 3rd argument specified");
goto Error; goto Error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment