mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-101410: Revert loghelper() change in 75f59bb
for integer input (GH-132625)
This commit is contained in:
parent
954b2cf031
commit
0c356c865a
2 changed files with 5 additions and 3 deletions
|
@ -2536,7 +2536,7 @@ class MathTests(unittest.TestCase):
|
||||||
math.log(x)
|
math.log(x)
|
||||||
x = -123
|
x = -123
|
||||||
with self.assertRaisesRegex(ValueError,
|
with self.assertRaisesRegex(ValueError,
|
||||||
f"expected a positive input, got {x}"):
|
"expected a positive input$"):
|
||||||
math.log(x)
|
math.log(x)
|
||||||
with self.assertRaisesRegex(ValueError,
|
with self.assertRaisesRegex(ValueError,
|
||||||
f"expected a float or nonnegative integer, got {x}"):
|
f"expected a float or nonnegative integer, got {x}"):
|
||||||
|
|
|
@ -2213,8 +2213,10 @@ loghelper(PyObject* arg, double (*func)(double))
|
||||||
|
|
||||||
/* Negative or zero inputs give a ValueError. */
|
/* Negative or zero inputs give a ValueError. */
|
||||||
if (!_PyLong_IsPositive((PyLongObject *)arg)) {
|
if (!_PyLong_IsPositive((PyLongObject *)arg)) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
/* The input can be an arbitrary large integer, so we
|
||||||
"expected a positive input, got %S", arg);
|
don't include it's value in the error message. */
|
||||||
|
PyErr_SetString(PyExc_ValueError,
|
||||||
|
"expected a positive input");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue