[Python-checkins] cpython: Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than
mark.dickinson
python-checkins at python.org
Fri Apr 11 20:35:15 CEST 2014
http://hg.python.org/cpython/rev/dc6c2ab7fec2
changeset: 90222:dc6c2ab7fec2
user: Mark Dickinson <dickinsm at gmail.com>
date: Fri Apr 11 14:34:40 2014 -0400
summary:
Issue #21193: Make (e.g.,) pow(2, -3, 5) raise ValueError rather than TypeError. Patch by Josh Rosenberg.
files:
Lib/test/test_builtin.py | 2 +-
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
Objects/longobject.c | 2 +-
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1085,7 +1085,7 @@
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)
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1111,6 +1111,7 @@
Case Roole
Timothy Roscoe
Erik Rose
+Josh Rosenberg
Jim Roskind
Brian Rosner
Guido van Rossum
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
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
diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -3841,7 +3841,7 @@
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;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list