https://github.com/python/cpython/commit/0c356c865a6d3806724f54d6d463b2e5289f6afa
commit: 0c356c865a6d3806724f54d6d463b2e5289f6afa
branch: main
author: Sergey B Kirpichev <skirpic...@gmail.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2025-04-17T10:55:00+03:00
summary:

gh-101410: Revert loghelper() change in 75f59bb for integer input (GH-132625)

files:
M Lib/test/test_math.py
M Modules/mathmodule.c

diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index bfc55e7bbaba0a..6ff7c40d81356b 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -2536,7 +2536,7 @@ def test_exception_messages(self):
             math.log(x)
         x = -123
         with self.assertRaisesRegex(ValueError,
-                                    f"expected a positive input, got {x}"):
+                                    "expected a positive input$"):
             math.log(x)
         with self.assertRaisesRegex(ValueError,
                                     f"expected a float or nonnegative integer, 
got {x}"):
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 20d3c3192ba2e4..bc259c91d9476e 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -2213,8 +2213,10 @@ loghelper(PyObject* arg, double (*func)(double))
 
         /* Negative or zero inputs give a ValueError. */
         if (!_PyLong_IsPositive((PyLongObject *)arg)) {
-            PyErr_Format(PyExc_ValueError,
-                         "expected a positive input, got %S", arg);
+            /* The input can be an arbitrary large integer, so we
+               don't include it's value in the error message. */
+            PyErr_SetString(PyExc_ValueError,
+                            "expected a positive input");
             return NULL;
         }
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to