]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101410: Revert loghelper() change in 75f59bb for integer input (GH-132625)
authorSergey B Kirpichev <skirpichev@gmail.com>
Thu, 17 Apr 2025 07:55:00 +0000 (10:55 +0300)
committerGitHub <noreply@github.com>
Thu, 17 Apr 2025 07:55:00 +0000 (10:55 +0300)
Lib/test/test_math.py
Modules/mathmodule.c

index bfc55e7bbaba0a8624c3b4eb857b34e35f1d4da6..6ff7c40d81356b42a06be7f7d8ca919a2f4743bd 100644 (file)
@@ -2536,7 +2536,7 @@ class MathTests(unittest.TestCase):
             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}"):
index 20d3c3192ba2e4620c70ba2cbaf65fa32295802b..bc259c91d9476e4167607c0000fa3c35d92c2001 100644 (file)
@@ -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;
         }