gh-101410: Revert loghelper() change in 75f59bb for integer input (GH… · python/cpython@0c356c8

2 files changed

lines changed

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}"):

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