]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-111342: fix typo in math.sumprod (GH-111416) (gh-111419)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 28 Oct 2023 05:27:33 +0000 (07:27 +0200)
committerGitHub <noreply@github.com>
Sat, 28 Oct 2023 05:27:33 +0000 (05:27 +0000)
Lib/test/test_math.py
Misc/NEWS.d/next/Library/2023-10-28-04-21-17.gh-issue-111342.m8Ln1k.rst [new file with mode: 0644]
Modules/mathmodule.c

index 2bda61012164d1d4c14774bbd34820a93947945b..faf067235c5dad1a43c13dd91dfb58aeaa3097ea 100644 (file)
@@ -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 (file)
index 0000000..57707fd
--- /dev/null
@@ -0,0 +1 @@
+Fixed typo in :func:`math.sumprod`.
index 7b1104ba5ac404e7cd3f47f59df18bac31dd0377..23fa2b181648c9ec0ca2fea8c9dbb10c31a2b47f 100644 (file)
@@ -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()) {