Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address review: improve message in loghelper()
  • Loading branch information
skirpichev committed Jan 23, 2025
commit 8d28fd8cba178d35efcea743d05e4e2d90f523ea
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