Skip to content

Commit 45fa12a

Browse files
authored
gh-101678: Merge math_1_to_whatever() and math_1() (#101730)
`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.
1 parent 5839575 commit 45fa12a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

Modules/mathmodule.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,7 @@ is_error(double x)
875875
*/
876876

877877
static PyObject *
878-
math_1_to_whatever(PyObject *arg, double (*func) (double),
879-
PyObject *(*from_double_func) (double),
880-
int can_overflow)
878+
math_1(PyObject *arg, double (*func) (double), int can_overflow)
881879
{
882880
double x, r;
883881
x = PyFloat_AsDouble(arg);
@@ -903,7 +901,7 @@ math_1_to_whatever(PyObject *arg, double (*func) (double),
903901
/* this branch unnecessary on most platforms */
904902
return NULL;
905903

906-
return (*from_double_func)(r);
904+
return PyFloat_FromDouble(r);
907905
}
908906

909907
/* 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))
951949
OverflowError.
952950
*/
953951

954-
static PyObject *
955-
math_1(PyObject *arg, double (*func) (double), int can_overflow)
956-
{
957-
return math_1_to_whatever(arg, func, PyFloat_FromDouble, can_overflow);
958-
}
959-
960952
static PyObject *
961953
math_2(PyObject *const *args, Py_ssize_t nargs,
962954
double (*func) (double, double), const char *funcname)

0 commit comments

Comments
 (0)