Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3f75b7

Browse files
[3.12] gh-111342: fix typo in math.sumprod (GH-111416) (gh-111419)
1 parent 2398036 commit c3f75b7

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

Lib/test/test_math.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ def test_sumprod_accuracy(self):
12921292
sumprod = math.sumprod
12931293
self.assertEqual(sumprod([0.1] * 10, [1]*10), 1.0)
12941294
self.assertEqual(sumprod([0.1] * 20, [True, False] * 10), 1.0)
1295+
self.assertEqual(sumprod([True, False] * 10, [0.1] * 20), 1.0)
12951296
self.assertEqual(sumprod([1.0, 10E100, 1.0, -10E100], [1.0]*4), 2.0)
12961297

12971298
@support.requires_resource('cpu')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed typo in :func:`math.sumprod`.

Modules/mathmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,7 @@ math_sumprod_impl(PyObject *module, PyObject *p, PyObject *q)
28312831
PyErr_Clear();
28322832
goto finalize_flt_path;
28332833
}
2834-
} else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(q_i))) {
2834+
} else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(p_i))) {
28352835
flt_q = PyFloat_AS_DOUBLE(q_i);
28362836
flt_p = PyLong_AsDouble(p_i);
28372837
if (flt_p == -1.0 && PyErr_Occurred()) {

0 commit comments

Comments
 (0)