]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101678: Merge math_1_to_whatever() and math_1() (#101730)
authorSergey B Kirpichev <skirpichev@gmail.com>
Thu, 9 Feb 2023 09:40:13 +0000 (12:40 +0300)
committerGitHub <noreply@github.com>
Thu, 9 Feb 2023 09:40:13 +0000 (09:40 +0000)
`math_1_to_whatever()` is no longer useful, since all existing uses of it convert to `float`.
Earlier versions of Python used `math_1_to_whatever` with an integer target; see
gh-16991 for the PR where that use was removed.

Modules/mathmodule.c

index 939954c95d9ff27205ba633816b3552120026f71..544560e8322c724e9e5f1ecb708b20772b8abb78 100644 (file)
@@ -875,9 +875,7 @@ is_error(double x)
 */
 
 static PyObject *
-math_1_to_whatever(PyObject *arg, double (*func) (double),
-                   PyObject *(*from_double_func) (double),
-                   int can_overflow)
+math_1(PyObject *arg, double (*func) (double), int can_overflow)
 {
     double x, r;
     x = PyFloat_AsDouble(arg);
@@ -903,7 +901,7 @@ math_1_to_whatever(PyObject *arg, double (*func) (double),
         /* this branch unnecessary on most platforms */
         return NULL;
 
-    return (*from_double_func)(r);
+    return PyFloat_FromDouble(r);
 }
 
 /* variant of math_1, to be used when the function being wrapped is known to
@@ -951,12 +949,6 @@ math_1a(PyObject *arg, double (*func) (double))
    OverflowError.
 */
 
-static PyObject *
-math_1(PyObject *arg, double (*func) (double), int can_overflow)
-{
-    return math_1_to_whatever(arg, func, PyFloat_FromDouble, can_overflow);
-}
-
 static PyObject *
 math_2(PyObject *const *args, Py_ssize_t nargs,
        double (*func) (double, double), const char *funcname)