Skip to content

Commit

Permalink
address review: improve message in loghelper()
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Jan 23, 2025
1 parent 169815d commit 8d28fd8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ def test_exception_messages(self):
math.log(x)
x = -123
with self.assertRaisesRegex(ValueError,
f"expected a positive input"):
f"expected a positive input, got {x}"):
math.log(x)
with self.assertRaisesRegex(ValueError,
f"expected a float or nonnegative integer, got {x}"):
Expand Down
4 changes: 2 additions & 2 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2232,8 +2232,8 @@ loghelper(PyObject* arg, double (*func)(double))

/* Negative or zero inputs give a ValueError. */
if (!_PyLong_IsPositive((PyLongObject *)arg)) {
PyErr_SetString(PyExc_ValueError,
"expected a positive input");
PyErr_Format(PyExc_ValueError,
"expected a positive input, got %S", arg);
return NULL;
}

Expand Down

0 comments on commit 8d28fd8

Please sign in to comment.