Skip to content

Commit 0c356c8

Browse files
authored
gh-101410: Revert loghelper() change in 75f59bb for integer input (GH-132625)
1 parent 954b2cf commit 0c356c8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/test/test_math.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,7 @@ def test_exception_messages(self):
25362536
math.log(x)
25372537
x = -123
25382538
with self.assertRaisesRegex(ValueError,
2539-
f"expected a positive input, got {x}"):
2539+
"expected a positive input$"):
25402540
math.log(x)
25412541
with self.assertRaisesRegex(ValueError,
25422542
f"expected a float or nonnegative integer, got {x}"):

Modules/mathmodule.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -2213,8 +2213,10 @@ loghelper(PyObject* arg, double (*func)(double))
22132213

22142214
/* Negative or zero inputs give a ValueError. */
22152215
if (!_PyLong_IsPositive((PyLongObject *)arg)) {
2216-
PyErr_Format(PyExc_ValueError,
2217-
"expected a positive input, got %S", arg);
2216+
/* The input can be an arbitrary large integer, so we
2217+
don't include it's value in the error message. */
2218+
PyErr_SetString(PyExc_ValueError,
2219+
"expected a positive input");
22182220
return NULL;
22192221
}
22202222

0 commit comments

Comments
 (0)