]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111342: fix typo in math.sumprod (GH-111416)
authorSergey B Kirpichev <skirpichev@gmail.com>
Sat, 28 Oct 2023 04:52:04 +0000 (07:52 +0300)
committerGitHub <noreply@github.com>
Sat, 28 Oct 2023 04:52:04 +0000 (23:52 -0500)
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 d5d2197c36b254defa7ee7117cfb6f2f055c9f54..bab732cdea5888ee45c1fb1dcf08c0cf75b7b1fd 100644 (file)
@@ -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 (file)
index 0000000..57707fd
--- /dev/null
@@ -0,0 +1 @@
+Fixed typo in :func:`math.sumprod`.
index a4d9466559235137a9df63b9826bb1d7c9ea6eb4..6cd61e9ab75424e692f8c5ba35813b07c3d95fca 100644 (file)
@@ -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()) {