Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Merge math_1_to_whatever() and math_1()"
This reverts commit 47970e2.
  • Loading branch information
skirpichev committed Feb 9, 2023
commit ee5e68929b9f94c4e5e5d7b0da43810b95d9a203
12 changes: 10 additions & 2 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,9 @@ is_error(double x)
*/

static PyObject *
math_1(PyObject *arg, double (*func) (double), int can_overflow)
math_1_to_whatever(PyObject *arg, double (*func) (double),
PyObject *(*from_double_func) (double),
int can_overflow)
{
double x, r;
x = PyFloat_AsDouble(arg);
Expand All @@ -901,7 +903,7 @@ math_1(PyObject *arg, double (*func) (double), int can_overflow)
/* this branch unnecessary on most platforms */
return NULL;

return PyFloat_FromDouble(r);
return (*from_double_func)(r);
}

/* variant of math_1, to be used when the function being wrapped is known to
Expand Down Expand Up @@ -949,6 +951,12 @@ 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