From 9dc4fb820439db26b223edce30e5313a2e3182ff Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 28 Oct 2023 07:52:04 +0300 Subject: gh-111342: fix typo in math.sumprod (GH-111416) --- Lib/test/test_math.py | 1 + Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst | 1 + Modules/mathmodule.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index d5d2197..bab732c 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -1325,6 +1325,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 a4d9466..6cd61e9 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2832,7 +2832,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()) { -- cgit v0.12