Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c356c8

Browse filesBrowse files
authored
gh-101410: Revert loghelper() change in 75f59bb for integer input (GH-132625)
1 parent 954b2cf commit 0c356c8
Copy full SHA for 0c356c8

File tree

Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed

‎Lib/test/test_math.py

Copy file name to clipboardExpand all lines: Lib/test/test_math.py
+1-1Lines changed: 1 addition & 1 deletion
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}"):

‎Modules/mathmodule.c

Copy file name to clipboardExpand all lines: Modules/mathmodule.c
+4-2Lines changed: 4 additions & 2 deletions
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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.