diff options
-rw-r--r-- | Lib/test/test_math.py | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst | 1 | ||||
-rw-r--r-- | Modules/mathmodule.c | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 2bda610..faf0672 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -1292,6 +1292,7 @@ class MathTests(unittest.TestCase): sumprod = math.sumprod self.assertEqual(sumprod([0.1] * 10, [1]*10), 1.0) self.assertEqual(sumprod([0.1] * 20, [True, False] * 10), 1.0) + self.assertEqual(sumprod([True, False] * 10, [0.1] * 20), 1.0) self.assertEqual(sumprod([1.0, 10E100, 1.0, -10E100], [1.0]*4), 2.0) @support.requires_resource('cpu') diff --git a/Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst b/Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst new file mode 100644 index 0000000..57707fd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst @@ -0,0 +1 @@ +Fixed typo in :func:`math.sumprod`. diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 7b1104b..23fa2b1 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2831,7 +2831,7 @@ math_sumprod_impl(PyObject *module, PyObject *p, PyObject *q) PyErr_Clear(); goto finalize_flt_path; } - } else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(q_i))) { + } else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(p_i))) { flt_q = PyFloat_AS_DOUBLE(q_i); flt_p = PyLong_AsDouble(p_i); if (flt_p == -1.0 && PyErr_Occurred()) { |