Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-101678: Merge math_1_to_whatever() and math_1() #101730

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,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);
Expand All @@ -1080,7 +1078,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
Expand Down Expand Up @@ -1128,12 +1126,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)
Expand Down