8000 address review: improve message in loghelper() · python/cpython@8d28fd8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d28fd8

Browse files
committed
address review: improve message in loghelper()
1 parent 169815d commit 8d28fd8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/test/test_math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,7 @@ def test_exception_messages(self):
25332533
math.log(x)
25342534
x = -123
25352535
with self.assertRaisesRegex(ValueError,
2536-
f"expected a positive input"):
2536+
f"expected a positive input, got {x}"):
25372537
math.log(x)
25382538
with self.assertRaisesRegex(ValueError,
25392539
f"expected a float or nonnegative integer, got {x}"):

Modules/mathmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,8 +2232,8 @@ loghelper(PyObject* arg, double (*func)(double))
22322232

22332233
/* Negative or zero inputs give a ValueError. */
22342234
if (!_PyLong_IsPositive((PyLongObject *)arg)) {
2235-
PyErr_SetString(PyExc_ValueError,
2236-
"expected a positive input");
2235+
PyErr_Format(PyExc_ValueError,
2236+
"expected a positive input, got %S", arg);
22372237
return NULL;
22382238
}
22392239

0 commit comments

Comments
 (0)
0