Skip to content

Commit f2e0142

Browse files
committed
pythongh-101410: revert loghelper() change in 75f59bb for integer input
1 parent b530e17 commit f2e0142

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/test/test_math.py

Lines changed: 1 addition & 1 deletion
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+
f"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

Lines changed: 4 additions & 2 deletions
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)