]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than TypeError....
authorMark Dickinson <dickinsm@gmail.com>
Fri, 11 Apr 2014 18:34:40 +0000 (14:34 -0400)
committerMark Dickinson <dickinsm@gmail.com>
Fri, 11 Apr 2014 18:34:40 +0000 (14:34 -0400)
Lib/test/test_builtin.py
Misc/ACKS
Misc/NEWS
Objects/longobject.c

index b561a6f73adc9690be0611e874931e44cd0c89f9..9d2725e592316079065bd1412a9549faf1351431 100644 (file)
@@ -1085,7 +1085,7 @@ class BuiltinTest(unittest.TestCase):
                     if isinstance(x, float) or \
                        isinstance(y, float) or \
                        isinstance(z, float):
-                        self.assertRaises(TypeError, pow, x, y, z)
+                        self.assertRaises(ValueError, pow, x, y, z)
                     else:
                         self.assertAlmostEqual(pow(x, y, z), 24.0)
 
index f1ed07c0e752b012fefde40d829a86890a9ada1b..437aa461dc3900c3706b428842d9fd7ec6cc52fa 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1111,6 +1111,7 @@ Armin Ronacher
 Case Roole
 Timothy Roscoe
 Erik Rose
+Josh Rosenberg
 Jim Roskind
 Brian Rosner
 Guido van Rossum
index dc61927775d277861a042d2b87531385a7b6da15..0b558727ba1cbdfe55f4ea89c73a70e934920247 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Release date: TBA
 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.
 
 - Issue #21134: Fix segfault when str is called on an uninitialized
index 7036c0ea4ad80292e620bf5936ecf3264737a91a..b749fd3d2df722fc51fded506ab4fa37a983dfee 100644 (file)
@@ -3841,7 +3841,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
 
     if (Py_SIZE(b) < 0) {  /* if exponent is negative */
         if (c) {
-            PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
+            PyErr_SetString(PyExc_ValueError, "pow() 2nd argument "
                             "cannot be negative when 3rd argument specified");
             goto Error;
         }